Ältere Kommentare anzeigen
I have loaded data that contain structures. The structures are of the form I have variable : struct1, struct2, struct3.... I have a 'file' with the list of these variables and want to manipulate the data contained in the structures with a for-loop.
Here is what I did:
for i = 1:numel(files)
data = files(i).data or data{1}.data
some code;
end
I have errors like : Improper index matrix reference and other errors, Cell contents reference from a non-cell array object.
2 Kommentare
Oleg Komarov
am 13 Aug. 2011
Please rephrase ("I want to analyse each of the file by giving a text file containing the name of the structures that I want to analyse") and be more clear, maybe with an example of what you have and waht you'd like to achieve: http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer
Charles
am 13 Aug. 2011
Akzeptierte Antwort
Weitere Antworten (1)
Jan
am 13 Aug. 2011
I'm not sure if this matchs your question, but similar question appear very often here:
If you use LOAD without catching the output to a variable, the output is directly written to the current workspace. Accessing these variables is probe to errors and often causes troubles, e.g. if a locally used variable is overwritten.
Therefore it is much safer and easier to use LOAD with catching the output:
data = load('File.mat');
field = fieldnames(data);
fprintf(' %s\n', field{:});
disp(data.field{1});
2 Kommentare
Charles
am 13 Aug. 2011
Jan
am 13 Aug. 2011
"I have variable" and "I have a 'file'" is not clear. What is the type andthe contents of "files"? Please post the code completely by editing the original question - *not* as comment or answer. And append a complete copy of the error message, because "and other error" is not exact enough to give an advice.
Kategorien
Mehr zu Variables finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!