3次元において、Zの値に対応するX,Yの値を紐づけたい
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
3次元において、
Zの値だけが表示されているとき、それに対応する X と Y の値を紐づけたいのですが、どのようにプログラムを作成したらよいのでしょうか。
例えば、このセルの値(Z)のX,Yの値は、(X,Y)=(2,5)です。
のように紐づけたいです。
0 Kommentare
Akzeptierte Antwort
Atsushi Ueno
am 29 Nov. 2021
見つけたいZの値を3次元データのZの値群と比較して、差分が閾値未満の値を見つけます。
[X,Y] = meshgrid(0:0.1:1);
Z = exp(X+Y); % 適当なデータを仮定
FindZ = 6.0496; % 表示されているZの値をZ=6.0496とします(同じZ値が3点見つかる場合です)
[row,col] = ind2sub(size(X),find(abs(Z-FindZ)<0.001)); % ここがポイントです
stem3(X,Y,Z); hold on;
for i=1:length(row)
disp(['このセルの値(' num2str(Z(row(i),col(i))) ')のX,Yの値は、(X,Y)=(' ...
num2str(X(row(i),col(i))) ',' num2str(Y(row(i),col(i))) ')です。']);
stem3(X(row(i),col(i)),Y(row(i),col(i)),Z(row(i),col(i)),'red','LineWidth',3);
end
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!