user1935350
user1935350

Reputation:

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.

Upvotes: 1

Views: 204

Answers (2)

Dims
Dims

Reputation: 50989

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

enter image description here

Upvotes: 3

Ilya Kobelevskiy
Ilya Kobelevskiy

Reputation: 5345

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');

Upvotes: 0

Related Questions