user1640255
user1640255

Reputation: 1304

MATLAB surf meshgrid issue - 2 vectors 1 matrix - surface plot

I have 2 vectors and one matrix and I would like to make a surface plot.

  1. first vector A , the distance vector A=1:1:100 (size 1 100);
  2. second vector B, the time vector B=1:1:10 (size 10);
  3. matrix C, every column has the data for each value of B (size 100 10)

How could I use the meshgrid and/or the surf function for getting a surface 3D plot?

Upvotes: 2

Views: 1487

Answers (1)

Luis Mendo
Luis Mendo

Reputation: 112679

[AA, BB] = ndgrid(A,B);
surf(BB,AA,C)

Or use the version of surf that allows two vectors as its two first inputs:

surf(B,A,C)

which for your particular vectors ([1 2 ...]) could be simplified to the single-input version

surf(C)

Upvotes: 2

Related Questions