MATLAB Answers

No data points appear on the graph when I hit run

4 views (last 30 days)
Aidan Palermo
Aidan Palermo on 13 Sep 2021
Edited: DGM on 13 Sep 2021
figure (1) %selects plotting window #1
plot(0, 98, 'c--', .02, 245, 'c--', .04, 490, 'c--', .05, 735, 'c--', .06, 931, 'c--', .08, 931, 'c--', .10, 980, 'c--');
I tried adding brackets like this ( [x,y,s,] ) and the graph itself dissapered

Answers (1)

DGM
DGM on 13 Sep 2021
Edited: DGM on 13 Sep 2021
When you plot points one at a time, they are rendered as single unconnected points. Since there is no specified marker type, they don't show up.
You could specify a marker type (i'm using blue so it shows up better against white on the web-view)
plot(0, 98, 'bx', .02, 245, 'bx', .04, 490, 'bx', .05, 735, 'bx', .06, 931, 'bx', .08, 931, 'bx', .10, 980, 'bx');
or you could plot the points as a series
clc
x = [0 0.02 0.04 0.05 0.06 0.08 0.10];
y = [98 245 490 735 931 931 980];
plot(x,y,'b--')

Community Treasure Hunt

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

Start Hunting!