Efficient way to plot data from a cell array?
25 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi everyone,
I've been struggling with finding a way to efficiently plot data which is stored in a cell array.
First of all, by efficiently I really mean to make the code understandable and maintainable later.
My data is organized as data series with some data (y) stored at different temperatures (x). I have several such data series, and since each data series might have various numner of samples, I've stored them in a cell array.
So data = {ds1 ds2 ds3 ds4 ...}, where each dsX is an Nx2 matrix containing my x and y values, N varies between data series.
Example:
ds1 = [ (1:4)' randn(4,1) ]
ds2 = [ (1:0.5:5)' randn(9,1) ]
ds3 = [ (2:0.1:3)' randn(11, 1) ];
data = {ds1 ds2 ds3}
Next, what I want to do with the data is: in one figure, for each dsX, plot dsX(:,2) vs dsX(:,1).
Actually I want the output to be the same as I would get from using plot like this:
plot(ds1(:,1), ds1(:,2), ds2(:,1), ds2(:,2), ds3(:,1), ds3(:,2), ...)
Preferable I would also like the handles to the lineseries objects, just as I would by adding h = before the call to plot above.
Codewise I don't know how many data series are stored in my cell array, so I cannot use the plot command directly as shown above.
I would really appreciate any suggestions to how I can efficiently plot my data as described. I can also consider proposals for how to organize my data in the first place.
0 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!