Plotting with arrays, no graph displayed

x = [6000,9375];
y = 10;
plot(x,y,'red')
title('x by y')
xlabel('x')
ylabel('y')

 Accepted Answer

Plotting one point requres a marker, and plotting a line requires at least two vectors of the same size.
Two options, depending on the result you want —
x = [6000,9375];
y = 10;
figure
plot(x,y,'pr')
title('x by y')
xlabel('x')
ylabel('y')
x = [6000,9375];
y = 10*ones(size(x));
figure
plot(x,y,'red')
title('x by y')
xlabel('x')
ylabel('y')
And of course, you can plot both markers and lines of various kinds connecting them.
.

2 Comments

Thank for your answer, it is very helpful
As always, my pleasure!

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products

Release

R2022a

Asked:

on 12 Mar 2023

Commented:

on 12 Mar 2023

Community Treasure Hunt

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

Start Hunting!