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

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

mesh plot with lines only

Asked by John on 13 Dec 2011

Hi,

I'm trying to plot 2 lines using the mesh function,

This is what I hoping to achieve. This example graph has 45 lines.

http://img39.imageshack.us/img39/9412/chartp.jpg

I don't really know what to do, if I import the data as column vectors like this:

x = load('x.txt.');
y1 = load('y1.txt.');
y2 = load('y2.txt.');

Could somebody advise me what the command would be to plot them using the mesh function.

I've searched online but cannot find an example similar to this. I just need to be pointed in the right direction.

Thank you

0 Comments

John

Tags

Products

No products are associated with this question.

1 Answer

Answer by Daniel on 13 Dec 2011

In the simplest case you have some data

M = 2;
N = 10;
x = 1:N;
y = 1:M;
z = randn(M, N);

and you create a mesh

mesh(x, y, z);

For you, assuming the text files are the correct sizes ...

M = 2;
y = 1:M;
x = load('x.txt');
N = length(x);
z = zeros(M, N);
for ii = 1:M
  z(ii, :) = load(['y', num2str(ii), '.txt']);
end 

Instead of mesh maybe you want

plot3(x, y'*ones(1, N), z)

4 Comments

John on 13 Dec 2011

apologies for miss-posting earlier

Daniel on 13 Dec 2011

I edited my question to include a plot3 option. Is that more what you are looking for?

John on 14 Dec 2011

many thanks

Daniel

Contact us