필터 지우기
필터 지우기

plotting a graph for cell

조회 수: 2 (최근 30일)
johnson saldanha
johnson saldanha 2018년 12월 10일
댓글: johnson saldanha 2018년 12월 11일
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
Guillaume
Guillaume 2018년 12월 10일
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.
johnson saldanha
johnson saldanha 2018년 12월 10일
i want simple line graph. the type is double and the cell elements have n number of rows and single column. so the number of rows will be my x axis

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
KSSV 2018년 12월 10일
% 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
KSSV
KSSV 2018년 12월 10일
YOu should show your whole code.....and also you should mention what is the error.
johnson saldanha
johnson saldanha 2018년 12월 11일
i got it thanks

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Guillaume
Guillaume 2018년 12월 10일
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
Guillaume
Guillaume 2018년 12월 10일
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.
johnson saldanha
johnson saldanha 2018년 12월 11일
yes i did that. but im not getting the markers

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by