필터 지우기
필터 지우기

Descending Axis Meshgrid Plotting

조회 수: 10 (최근 30일)
Chris Berry
Chris Berry 2011년 4월 28일
댓글: Asawari 2013년 10월 18일
[EDIT: 20110512 16:59 - reformat - WDR]
Dear fellow MATLAB Users,
I am plotting data over a meshgrid, and would like to reverse the plotted "Y" axis from ascending to descending. For some reason, when changing my meshgrid parameters to allow for this, I am prompted with a 1x1 plotting window. Here is my code as it stands before making my alteration:
__________ CODE START __________
z=zeros(1,12);
xD=[1600;1666;1730;1780;1810;1800;1780;1770;1740;1720;1670;1610];
yD=[700;730;790;860;980;1030;1020;1100;1070;1030;970;930];
[x,y] = meshgrid(487:4:2074, 213:4:1106);
z_sum = 0*x;
h = surf(x,y,z_sum,'linestyle','none');
axis image
for i=1:numel(xD);
z=550 - 4.2*sqrt((x-xD(i)).^2+(y-yD(i)).^2);
z(z<0) = 0;
z_sum = z_sum + z;
set(h,'zdata',z_sum);
view([0 90])
drawnow;
pause(.01);
end
__________ CODE END __________
This will return my desired plot, with exception to a descending "Y" axis. This is how my code appears after alterating:
__________ NEW CODE START __________
z=zeros(1,12);
xD=[1600;1666;1730;1780;1810;1800;1780;1770;1740;1720;1670;1610]; yD=[700;730;790;860;980;1030;1020;1100;1070;1030;970;930];
[x,y] = meshgrid(487:4:2074, 1106:4:213);
z_sum = 0*x; h = surf(x,y,z_sum,'linestyle','none'); axis image
for i=1:numel(xD); z=550 - 4.2*sqrt((x-xD(i)).^2+(y-yD(i)).^2); z(z<0) = 0; z_sum = z_sum + z; set(h,'zdata',z_sum); view([0 90]) drawnow; pause(.01); end
__________ NEW CODE END __________
Notice how a 1x1 unit plot is created. I cannot understand why this is occurring, nor what to do to remedy it. Any help that could be lent to solve this issue would be greatly appreciated.
Thank you,
~ Chris
  댓글 수: 1
Asawari
Asawari 2013년 10월 18일
Hi.I am facing the same problem.I am applying mesh command and I want to arrange the axes in descending order instead of ascending.If you have got the answer can you please help me out also?

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

채택된 답변

Chris Berry
Chris Berry 2011년 4월 28일
[EDIT: 20110512 16:57 - reformat - WDR]
Add set(gca,'ydir','rev').
z_sum = 0*x;
h = surf(x,y,z_sum,'linestyle','none');
axis image
for i=1:numel(xD);
z=550 - 4.2*sqrt((x-xD(i)).^2+(y-yD(i)).^2); % 2-D Gaussian Curve
z(z<0) = 0;
z_sum = z_sum + z;
set(h,'zdata',z_sum);
set(gca,'ydir','rev')
alpha(.8) % Plot Transparency (Dramatically Slows Output)
view([0 90]) % Plot orientation
drawnow;
pause(.01); % Plot time delay
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by