How can I plot 1x6 cell?
Mostrar comentarios más antiguos
I want to plot graph for w. w contains 1x6 cell. Inside the 1x6 cell, it contains another cell that is 1x2 cells. Each of the 1x2 cell contains 1x1920 double.
Therefore, how can I plot the graph?
The code that I have been try:
figure
hold on
for i = 1:length(w)
plot(C{w}) ;
end
legend
1 comentario
Aida Mohd
el 24 de Mzo. de 2021
Respuestas (1)
There are surely more succinct ways to do this, but I find that I'd rather have control over each individual plot series. First, I'm just going to generate a thing to plot. You already have this.
% make example array
time=1:100;
outer=cell([1 6]);
for p=1:6
data=rand([1 100])+p; % i'm adding an offset just for appearances
inner={time,data};
outer{p}=inner;
end
Then I rearrange the data to make indexing easier and plot it. I'm assuming each 1x2 inner cell is a series, but otherwise the indexing can be similar. As I chose to do it one series at a time, I can specify the line type (and potentially other options) for each explicitly.
outer=vertcat(outer{:});
linetypes={'b','k','r','g','m',':k'};
legendstrings={'this one','that one','the other one', ...
'the best one','the worst one','idk about this one'};
for p=1:size(outer,1)
h(p)=plot(outer{p,1},outer{p,2},linetypes{p});
hold on
end
% you'll probably have to specify the legend location
% as things might get crowded in the plot box
legend(h,legendstrings)
I'm sure someone can come up with something more robust or elegant, but I think this should be fairly straightforward.
1 comentario
Aida Mohd
el 24 de Mzo. de 2021
Categorías
Más información sobre Annotations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!