Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
ploting two vectors

Subject: ploting two vectors

From: Abdul Rauf Anwar

Date: 6 Sep, 2010 15:14:08

Message: 1 of 3

Hi
Assume i have two vectors of length 20 , that are x and y
i want to plot them in same plot ( with different color ) but agaisnt same vector z ( on x axis ) , take z vector as
z= 1:1:20;
i cant figure out how to do this ?
Thanks in anticipation

Subject: ploting two vectors

From: Sadik

Date: 6 Sep, 2010 16:52:05

Message: 2 of 3

Hi Abdul Rauf,

z = 1:20;

figure % new figure window
plot(z,x)
hold on %hold the z-x plot so that we won't lose it
plot(z,y,'r')
legend('x','y')

Best.

Subject: ploting two vectors

From: Matt Fig

Date: 6 Sep, 2010 17:00:23

Message: 3 of 3

Also, for a case like this.

% Data
x = (1:20).^2; % Row vector of length 20.
y = (1:20).^2.1;

% Engine
plot([x.' y.']) % Plot each column of a matrix against its index.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us