Is it possible to add an element to a "sub array"?
Ältere Kommentare anzeigen
Im not sure what the proper term for this structure is in Matlab, but I have the following variable
stateMeasurements = {[] [] [] [] []};
Every array is supposed to contain basically a pair of start time and end time, so if I want to add a measurement for State 1 for example, I would like to do something like this
stateMeasurements(1).push([5, 10]);
I can first get the sub array and add the measurement to it, but then I can put it back into stateMeasurements.
m = stateMeasurements(1);
m{end+1}=[5, 10];
stateMeasurements(1) = m % This gives an error
The error I receive is "Unable to perform assignment because the left and right sides have a different number of elements."
I know how to achieve this in other programming languages but how can I do this in Matlab?
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Creating and Concatenating Matrices 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!