Slice a surf plot at certain x and y valus

27 views (last 30 days)
Martin
Martin on 8 May 2014
Commented: Star Strider on 22 May 2014
I have as set of f(x,y) data which I inperpoled useing scatteredInterpolant. Then I've displayed the data useing meshgrid and surf.
Now I would like to cut trough that surface at certain x any y values. I do not have volumetric data so I can not use slice or contourslice.
I would like do recive a contour of the surface at a given x or y value.
Does anyone have an idea?
Thank you
F = scatteredInterpolant(x,y,z);
dimx=(max(x)-min(x))/30;
dimy=(max(y)-min(y))/30;
xw = min(x):dimx:max(x);
yw = min(y):dimy:max(y);
[xq,yq] = meshgrid(xw,yw);
zq = F(xq,yq);
surf(xq,yq,zq);

Answers (2)

Star Strider
Star Strider on 8 May 2014
If you only want to view the plot between certain x and y values, the axis function might do what you want. You can set the x and y axis limits to whatever interval you want. They will be the same whether you use surf, surfc, contour, or any of the others.
If you want to extract the data from x and z for a particular value of y, or y and z for a particular value of x, that is simply the way you would extract row or column data from any matrix.
  1 Comment
Star Strider
Star Strider on 22 May 2014
‘thank you for your answer.
The axis function is not what i look for because i want to desplay the cuts in 2d and extracting rows or columns does not work eather beacouse ther are just a certain number of columns and the rest is interpolated. i want to be able to cut at any x and y value.
any suggestions?’_
See if the slice function will do what you want.

Sign in to comment.


Martin
Martin on 22 May 2014
thank you for your answer.
The axis function is not what i look for because i want to desplay the cuts in 2d and extracting rows or columns does not work eather beacouse ther are just a certain number of columns and the rest is interpolated. i want to be able to cut at any x and y value.
any suggestions?

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!