How can I turn the following code to a surface plot
古いコメントを表示
function Visualize2(X, Y, E, F, k)
if k==4
k1=2; k2=2;
elseif k==2
k1=1; k2=2;
end
figure;
X=X'; Y=Y'; E=E'; F=F';
%Show the original manifolds
subplot(k1,k2,1);
plot3(X(:,1), X(:,2), X(:,3),'r-', 'LineWidth',.5);
hold on;
plot3(Y(:,1), Y(:,2), Y(:,3),'b-', 'LineWidth',.5);
title({['(A) Before Alignment']});
xlabel('X', 'FontSize',12, 'FontWeight', 'bold');
ylabel('Y', 'FontSize',12, 'FontWeight', 'bold');
zlabel('Z', 'FontSize',12, 'FontWeight', 'bold');
% 3D
subplot(k1,k2,4);
plot3(E(:,1), E(:,2), E(:,3),'r-', 'LineWidth',.5);
hold on;
plot3(F(:,1), F(:,2), F(:,3),'b-', 'LineWidth',.5);
title({['(B) After 3D Alignment']});
xlabel('X', 'FontSize',12, 'FontWeight', 'bold');
ylabel('Y', 'FontSize',12, 'FontWeight', 'bold');
zlabel('Z', 'FontSize',12, 'FontWeight', 'bold');
if k==4
% 2D
subplot(k1,k2,3);
plot(E(:,1), E(:,2), 'r-', 'LineWidth',.5);
hold on;
plot(F(:,1), F(:,2), 'b-', 'LineWidth',.5);
title({['(C) After 2D Alignment']});
xlabel('X', 'FontSize',12, 'FontWeight', 'bold');
ylabel('Y', 'FontSize',12, 'FontWeight', 'bold');
zlabel('Z', 'FontSize',12, 'FontWeight', 'bold');
% 1D
subplot(k1,k2,2);
plot(E(:,1), 'r-', 'LineWidth',.5);
hold on;
plot(F(:,1), 'b-', 'LineWidth',.5);
title({['(D) After 1D Alignment']});
xlabel('X', 'FontSize',12, 'FontWeight', 'bold');
ylabel('Y', 'FontSize',12, 'FontWeight', 'bold');
zlabel('Z', 'FontSize',12, 'FontWeight', 'bold');
end
end
10 件のコメント
darova
2020 年 1 月 18 日
Use griddata
Zain Khaliq
2020 年 1 月 18 日
編集済み: Zain Khaliq
2020 年 1 月 18 日
darova
2020 年 1 月 18 日
Try this
title('(A) Before Alignment');
Instead of
title({['(A) Before Alignment']});
Its faster
Zain Khaliq
2020 年 1 月 18 日
Walter Roberson
2020 年 1 月 18 日
You should use scatteredInterpolant() to create your 3D plots.
F = scatteredInterpolant(X(:,1), X(:,2), X(:,3));
[xq1, xq2] = meshgrid(-5:.1:5); %use an appropriate range of values and spacing
xq3 = F(xq1, xq2);
mesh(xq1, xq2, xq3)
Zain Khaliq
2020 年 1 月 19 日
Walter Roberson
2020 年 1 月 19 日
F1 = scatteredInterpolant(X(:,1), X(:,2), X(:,3));
[xq1, xq2] = meshgrid(-5:.1:5); %use an appropriate range of values and spacing
xq3 = F1(xq1, xq2);
mesh(xq1, xq2, xq3);
hold on
F2 = scatteredInterpolant(Y(:,1), Y(:,2), Y(:,3));
[yq1, yq2] = meshgrid(-5:.1:5); %use an appropriate range of values and spacing
yq3 = F2(yq1, yq2);
mesh(yq1, yq2, yq3);
hold off
Zain Khaliq
2020 年 1 月 19 日
編集済み: Zain Khaliq
2020 年 1 月 19 日
Walter Roberson
2020 年 1 月 19 日
mesh(xq1, xq2, xq3, 'r');
and
mesh(yq1, yq2, yq3, 'b');
and
title('(A) Before Alignment')
Zain Khaliq
2020 年 1 月 19 日
回答 (1 件)
Image Analyst
2020 年 1 月 18 日
Use surf()
surf(X(:,1), X(:,2), X(:,3), 'EdgeColor', 'none');
If that doesn't work, attach your X, Y, E, F, and k in a .mat file with the paper clip icon.
7 件のコメント
Zain Khaliq
2020 年 1 月 18 日
Image Analyst
2020 年 1 月 18 日
If it's too large to share, you're not going to see everything on the surface when it's subsampled for display. So just subsample your data and give us a smaller set of data.
Zain Khaliq
2020 年 1 月 18 日
Image Analyst
2020 年 1 月 18 日
What happens if you just do
surf(x, y, z)
using x, y, and z that are appropriate for the data you want?
Zain Khaliq
2020 年 1 月 18 日
Zain Khaliq
2020 年 1 月 18 日
Image Analyst
2020 年 1 月 19 日
Sorry but I'm not going to be able to have the time to donate to you to delve into this. Basically you need to figure out how to use surf() if you want a surface plot. It should not be hard or beyond your capabilities - you're a smart scientist so I'm sure you can do it.
カテゴリ
ヘルプ センター および File Exchange で Surface and Mesh Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!