Plot a curve as a vertical 3D surface in MATLAB?

9 ビュー (過去 30 日間)
Preston Quine
Preston Quine 2017 年 11 月 22 日
編集済み: Star Strider 2017 年 11 月 22 日
I have two vectors of data, say x and y, corresponding to the discrete x and y coordinates of a curve in 2D space. I want to plot this curve with a fixed height, say z = 1, in 3D to form a surface. (The goal is to visualize the intersection of this surface with another surface plot). Below is an image that depicts what I want to do. Any ideas on how this could be accomplished?

採用された回答

Star Strider
Star Strider 2017 年 11 月 22 日
編集済み: Star Strider 2017 年 11 月 22 日
Try this:
x = linspace(0, 2*pi, 50); % Independent Variable
y = sin(x); % Dependent Variable
z = [ones(size(x)); zeros(size(x))]; % ‘Z’ Matrix
figure(1)
surf([x; x], [y; y], z)
grid on
axis equal
Also, if you want more ‘levels’ in the z-direction:
x = linspace(0, 2*pi, 50); % Independent Variable
y = sin(x); % Dependent Variable
z = [(1:-0.2:0)'*ones(size(x))]; % ‘Z’ Matrix
figure(1)
surf(repmat(x,size(z,1),1), repmat(y,size(z,1),1), z)
grid on
axis equal
The ‘(1:-0.2:0)’ in the z calculation sets the number of ‘levels’ and values of the ‘levels’. Experiment with it to get the result you want.
NOTE This requires x and y to be row vectors.
EDIT Added plot image.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by