1
votes

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?

1

1 Answers

1
votes
[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)