plotting a single vector out of a multidimensional array?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I've got an M-file that calculates error data and stores it in a multidimensional array. 1st Dimension determines which dataset I refer to, 2nd dimension determines which sensor in a multi-sensor array the measurements are from, and the 3rd dimension is finally the calculated error at each point of the original signal.
I'm thus just using a multi-dimensional array as a way to store all of the error vectors in a single structure. But, when I try to plot a single error vector at given index values for the 1st and 2nd dimensions using the plot command, I get matlab errors:
>>plot(Xhat(1,3,:));
"Error using plot Data may not have more than 2 dimensions"
Why won't that work? I've specified a 1-dimensional set of data for it to plot, but it won't do it? How should I approach this differently?
0 Kommentare
Akzeptierte Antwort
Cedric
am 9 Apr. 2013
Bearbeitet: Cedric
am 9 Apr. 2013
You have two singleton dimensions when you index Xhat(1,3,:). Look at the following:
>> A = rand(2,3,4) ;
>> v = A(1,2,:)
v(:,:,1) =
0.4168
v(:,:,2) =
0.9841
v(:,:,3) =
0.3395
v(:,:,4) =
0.4228
>> size(v)
ans =
1 1 4
>> v = squeeze(A(1,2,:))
v =
0.4168
0.9841
0.3395
0.4228
>> size(v)
ans =
4 1
If you don't index across datasets too often, I would recommend switching your dimensions, e.g having sensor x point x dataset. This would simplify the indexing and make it (much) more efficient if you have large datasets.
2 Kommentare
Cedric
am 9 Apr. 2013
You're welcome! Please read the last note that I wrote maybe after you saw my answer.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!