3D plot with different x-y resolution

2 ビュー (過去 30 日間)
Lee
Lee 2018 年 7 月 4 日
コメント済み: Walter Roberson 2018 年 7 月 4 日
Can I do a 3D plot of a set of x-y-z with different resolution? For example:
  • x1=[0, 0.5, 1.0]; y1=[2, 3, 6]; z1=[1];
  • x2=[0, 0.3, 0.6, 1.0]; y2=[8, 2, 3, 6]; z2=[2];
  • x3=[0, 0.2, 0.4, 0.6, 0.8, 1.0]; y3=[8, 9, 4, 2, 3, 6]; z3=[3];
Many thanks!

回答 (1 件)

Star Strider
Star Strider 2018 年 7 月 4 日
Yes. However you cannot plot a scalar against vectors, so one way to do it would be:
x1=[0, 0.5, 1.0];
y1=[2, 3, 6];
z1=[1] * ones(size(x1));
figure
plot3(x1, y1, z1)
grid on
This creates a vector for ‘z1’, and plot3 will plot it.
Similarly, if you want to plot a mesh or surf plot, create ‘z1’ as a matrix:
x1=[0, 0.5, 1.0];
y1=[2, 3, 6];
z1=[1] * ones(size(x1,2));
figure
mesh(x1, y1, z1)
grid on
Experiment to get the result you want.
  3 件のコメント
Star Strider
Star Strider 2018 年 7 月 4 日
My pleasure!
This works:
x1=[0, 0.5, 1.0]; y1=[2, 3, 6]; z1=[1];
x2=[0, 0.3, 0.6, 1.0]; y2=[8, 2, 3, 6]; z2=[2];
x3=[0, 0.2, 0.4, 0.6, 0.8, 1.0]; y3=[8, 9, 4, 2, 3, 6]; z3=[3];
figure
mesh(x1, y1, z1*ones(numel(x1)))
hold on
mesh(x2, y2, z2*ones(numel(x2)))
mesh(x3, y3, z3*ones(numel(x3)))
hold off
grid on
Walter Roberson
Walter Roberson 2018 年 7 月 4 日
mesh(x1, y1, z1*ones(length(y1), length(x1)))
You might need to reverse the order of the length calls.

サインインしてコメントする。

カテゴリ

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