How to extract data from a slice?

12 ビュー (過去 30 日間)
John
John 2016 年 12 月 1 日
回答済み: KSSV 2016 年 12 月 1 日
The example in "doc slice" is very good:
hsp = surf(linspace(-2,2,20),linspace(-2,2,20),zeros(20)+1);
rotate(hsp,[1,-1,1],30)
xd = get(hsp,'XData');
yd = get(hsp,'YData');
zd = get(hsp,'ZData');
delete(hsp)
[x,y,z] = meshgrid(-2:.2:2,-2:.25:2,-2:.16:2);
v = x.*exp(-x.^2-y.^2-z.^2);
slice(x,y,z,v,xd,yd,zd);
How can the data of this slice be extracted as a "2D matrix slice" and used later to show with imshow for example?

採用された回答

KSSV
KSSV 2016 年 12 月 1 日
Already you did it...The code you gave has the way to extract the data you want.
hsp = surf(linspace(-2,2,20),linspace(-2,2,20),zeros(20)+1);
rotate(hsp,[1,-1,1],30)
xd = get(hsp,'XData');
yd = get(hsp,'YData');
zd = get(hsp,'ZData');
delete(hsp)
[x,y,z] = meshgrid(-2:.2:2,-2:.25:2,-2:.16:2);
v = x.*exp(-x.^2-y.^2-z.^2);
hss = slice(x,y,z,v,xd,yd,zd);
xs = get(hss,'XData');
ys = get(hss,'YData');
zs = get(hss,'ZData');
cs = get(hss,'CData');
figure
surf(xs,ys,zs,cs) ;
You have the data xs,ys,zs,cs in your hand now.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by