extract fig into surf(x,y,z)

2 ビュー (過去 30 日間)
feynman feynman
feynman feynman 2024 年 12 月 4 日
コメント済み: Image Analyst 2024 年 12 月 30 日
There's a .fig that plots n z(x) curves, each of which corresponds to 1 y value (n=3 in the illustration). The y values are known data. I don't have those z(x) data besides this .fig. How to convert this fig into a surf(x,y,z) plot?
  5 件のコメント
feynman feynman
feynman feynman 2024 年 12 月 29 日
編集済み: feynman feynman 2024 年 12 月 29 日
Thank you so much it works.
It even works when hfig isn't lines but dots. But if hfig is just dots, why does matlab still identify them as lines and group them into several clusters?
Walter Roberson
Walter Roberson 2024 年 12 月 29 日
If hfig is dots but the code succeeds in creating a surface, then the implication is that the dots were created as line() objects with 'linestyle', 'none' instead of being created as scatter() objects. Creating dots as line() objects instead of as scatter() objects is fairly common.
The code gathers all of the XData and YData of the line() objects and ignores what the 'linestyle' is set to for the line() objects.

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

採用された回答

Star Strider
Star Strider 2024 年 12 月 4 日
One way is tto enlarge the y-values to a matrix using repmat and then offset them by adding a different constant to each column (in this example).
x = linspace(0, 1).';
z = sin(2*pi*x*(1:3));
y = ones(size(z,1),1);
xm = repmat(x, 1, size(z,2));
ym = repmat(y, 1, size(z,2));
figure
plot3(xm, ym, z)
grid
colormap(turbo)
title('‘plot3’ Using ‘Original’ Y-Values')
figure
surf(xm, ym, z)
grid on
colormap(turbo)
title('‘surf’ Using ‘Original’ Y-Values')
ym = ym + (0:2); % Create ‘Offset’ ‘Y’-Values
figure
surf(xm, ym, z)
grid on
colormap(turbo)
title('‘surf’ Using ‘Offset’ Y-Values')
.
  2 件のコメント
feynman feynman
feynman feynman 2024 年 12 月 29 日
移動済み: Stephen23 2024 年 12 月 29 日
both answers are great. I don't know which to accept.
Image Analyst
Image Analyst 2024 年 12 月 30 日
@DGM posted his as a comment, not an Answer, so you can't accept his or even vote for it. Only @Star Strider posted an actual answer so unless DGM changes/moves his to an Answer you can only accept Star's.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePrinting and Saving についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by