Matlab produces empty figure when using plot(x,y,'-')
Show older comments
Hi, I have a code that works fine, its meant to plot time t over a variable A. the plot function works when i specify plot(t,A,'*'), but produces an empty figure when i use any other marker ( for example using 'o' or '-' will produce an empty figure), and when I dont specify a marker. I am on MacOS version 12.1.
example: this conde works and produces a graph
A = 20
t = 0
while t < 20
A = A + 1
t = t + 1
plot(t,A,'*')
hold on
end
however this:
A = 20
t = 0
while t < 20
A = A + 1
t = t + 5
plot(t,A,'-')
hold on
end
creats an empty figure.
1 Comment
Walter Roberson
on 1 Apr 2022
'-' is not a marker: it is a plot line style.
I would, though, expect 'o' to work as a marker.
Accepted Answer
More Answers (1)
A = 20
Ap = A;
t = 0
tp = t;
while t < 20
A = A + 1
Ap = [Ap, A];
t = t + 5
tp = [tp, t];
end
figure
plot(tp, Ap, '-')
1 Comment
Mia DeCataldo
on 2 Apr 2022
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
