Unable to plot 2 columns of a matrix against each other

1 view (last 30 days)
Hello, I have a 466x2 matrix and I am trying to plot column 1 on the x-axis and column 2 on y. For that, I am trying the following:
I have the matrix antenna1 as
Column 1 Column 2
0.047393 2530
0.047393 2529
0.097389 2513
0.097389 2491
0.147392 2462
0.147392 2423
0.19739 2387
0.19739 2353
0.247396 2328
0.247396 2310 .... and so on
I am plotting the graph using:
figure
hold on
plot(antenna1(:,1),antenna1(:,2))
I get the following graph for this:
This graph shows both lines plotted on the y-axis. I want column 1 on x and column 2 on y.
How do I achieve this?
Thanks for any help.
Pranav

Accepted Answer

KSSV
KSSV on 6 Dec 2016
Try
n = 1 ; % play around with n
plot(antenna1(1:end-n,1),antenna1(1:end-n,2))
  1 Comment
Pranav Thiagarajan
Pranav Thiagarajan on 6 Dec 2016
Thank you. It was due to extra pre-initialised rows and columns that were set to 0.

Sign in to comment.

More Answers (0)

Categories

Find more on Line Plots 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!