plotting a graph for cell
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
johnson saldanha
el 10 de Dic. de 2018
Comentada: johnson saldanha
el 11 de Dic. de 2018
i have a cell array. it has a 12 rows and 1 column. i want to plot the graph for each cell element in the same graph. each cell element should differ in appearance. like circles, triangles and so on.
2 comentarios
Guillaume
el 10 de Dic. de 2018
What's in each cell of the cell array (size and type)?
What does the graph refers to? Matlab has many graph plotting functions from simple line graphs to bar, chart, etc. graphs.
Respuesta aceptada
KSSV
el 10 de Dic. de 2018
% make random data
C = cell(5,1) ;
for i =1:5
C{i} = rand(10,1) ;
end
% plot
str = {'.-r','*-k','d-g','^-y','O-b'} ;
figure
hold on
for i = 1:length(C)
plot(C{i},str{i}) ;
end
legend
But my suggestion woul dbe to go by color instead of markers.
% make random data
C = cell(5,1) ;
for i =1:5
C{i} = rand(10,1) ;
end
% plot
figure
hold on
for i = 1:length(C)
plot(C{i}) ;
end
legend
3 comentarios
KSSV
el 10 de Dic. de 2018
YOu should show your whole code.....and also you should mention what is the error.
Más respuestas (1)
Guillaume
el 10 de Dic. de 2018
The simplest way to plot each vector:
figure;
hold on;
hlines = cellfun(@plot, yourcellarray);
This will plot each vector in a different colour (according to the colourorder property of the figure). Matlab does not have an automatic way to cycle between different markers but you can change them afterward:
markers = {'o', '+', '*', '.', 'x', 's', 'd', '^', 'v', '>', '<', 'p'}; %12 different markers
[hlines.Marker] = markers{:};
3 comentarios
Guillaume
el 10 de Dic. de 2018
The lines
markers = {'o', '+', '*', '.', 'x', 's', 'd', '^', 'v', '>', '<', 'p'}; %12 different markers
[hlines.Marker] = markers{:};
will definitively change the markers of the 12 lines to 12 different markers.
Ver también
Categorías
Más información sobre Line Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!