How can I turn the following code to a surface plot

조회 수: 1 (최근 30일)
Zain Khaliq
Zain Khaliq 2020년 1월 18일
댓글: Image Analyst 2020년 1월 19일
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
Walter Roberson
Walter Roberson 2020년 1월 19일
mesh(xq1, xq2, xq3, 'r');
and
mesh(yq1, yq2, yq3, 'b');
and
title('(A) Before Alignment')
Zain Khaliq
Zain Khaliq 2020년 1월 19일
the title thing worked, however for color i get the follwoing error :
Error using mesh (line 63)
Property value pairs expected.
Error in Visualize1 (line 69)
mesh(xq1, xq2, xq3,'g');
Error in cmp2All (line 39)
Visualize1(X1, X2, map1(:,1:3)'*X1, map2(:,1:3)'*X2, 4);

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
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
Zain Khaliq 2020년 1월 18일
were you able to see the code? from the link I provided above ? the problem is my professor doesnt like the lines in that graph, beacuse when I replace the authors data with mine and run the code, my data looks like its noise signal, eventho its not so my professor said if you can represent these as surface plot it would look much smoother.
Image Analyst
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by