简体   繁体   中英

Simple MATLAB Graph Plotting

This may be an obviously simple question, but i'm not sure how to do this.

I have 4 calculated values stored in 4 variables, each representing a condition. I want to simply display each of these in a graph with the condition/variable on the X axis and the values on the Y axis. I have tried the code below, but it just gives me a blank figure with values but no line.

figure(1)
T = TA;
S = SA;
U = UA;
O = OA;
plot(T,S,U,O, '--o')
shg

Thanks in advance.

Try this

figure(1)
T = 12;
S = 7;
U = 5;
O = 10;
plot([T,S,U,O], '--o');
set(gca,'XTick',[1,2,3,4]);
set(gca,'XTickLabel',{'T','S','U','O'})
shg

for me this gave

在此输入图像描述

Check matlab help on plot and specifically linespecs to define the format you would like the data plotted in. For example, code below plots each variable in different color with line and symbol.

 figure;
 hold on;
 plot(T,'-bo');
 plot(S,'-g.');
 plot(U,'-rd');
 plot(O,'-mx');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM