multiple graph in one figure
古いコメントを表示

Hello, I have data that are in results.txt, trying to achieve a graph similar to this one created on excel.
this is what I have done on matlab. I am not getting the result I need. on top of that I am sure there is an easier way to do that. it will be great if someone can help.
textFileName = ['results.txt'];
M = dlmread(textFileName);
for runs = 1:40
PS(runs)=M(runs,1);
RS(runs)=M(runs,2);
N(runs)=M(runs,3);
PSK(runs)=M(runs,4);
if PS(runs)==100
plot(N,PSK,'k')
grid on
elseif PS(runs)==250
plot(N,PSK,'b')
grid on
elseif PS(runs)==500
plot(N,PSK,'g')
grid on
elseif PS(runs)==750
plot(N,PSK,'r')
grid on
elseif PS(runs)==1000
plot(N,PSK,'c')
grid on
elseif PS(runs)==2500
plot(N,PSK,'m')
grid on
end
end
Thanks a lot.
1 件のコメント
Stephen23
2016 年 1 月 8 日
Ayman El Hajjar's "Answer" moved here:
this is an extract of my data
100 8 10 33.33
100 8 25 57.14
100 8 50 52.09
100 8 100 50.52
250 13 10 27.26
250 13 100 52.85
250 13 200 52.45
250 13 250 50.43
500 18 10 0.00
500 18 25 46.15
500 18 500 49.49
750 22 10 16.67
750 22 25 54.55
750 22 500 50.97
750 22 750 49.91
1000 25 10 0.00
1000 25 25 55.61
1000 25 50 53.60
1000 25 750 49.66
1000 25 1000 54.01
2500 41 10 16.67
2500 41 25 48.48
2500 41 1000 49.54
2500 41 2500 49.17
回答 (1 件)
Jos (10584)
2016 年 1 月 8 日
Take a look at the function hold
Create some data
x = 1:10
y1 = 2*x+3
y2 = 3*x-4
plot(x,y1,'mo-') ;
hold on
plot(x,y2,'rs:') ;
hold off
5 件のコメント
Jos (10584)
2016 年 1 月 8 日
or in one go:
plot(x,y1,'mo-',x,y2,'rs:')
Ayman El Hajjar
2016 年 1 月 8 日
Steven Lord
2016 年 1 月 8 日
How specifically is what you're looking for different than the behavior you receive with HOLD or plotting multiple lines in one PLOT call?
Ayman El Hajjar
2016 年 1 月 8 日
Ayman El Hajjar
2016 年 1 月 8 日
カテゴリ
ヘルプ センター および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!