简体   繁体   中英

MATLAB surface plot inputs

I wrote code that plots 2 subplots, a 3D surface plot and a 2D contour plot. However, the variables/vectors used in the plots change and I need to re-plot them. Here is what I have so far. I keep getting and error and MATLAB crashes every time I run the code.

Plot that works:

subplot(2,1,1);
plotHandle =     surf(xMeters(xStart:xEnd),yMeters(yStart:yEnd),ELEV(yStart:yEnd,xStart:xEnd));
subplot(2,1,2);
contour(xMeters,yMeters,ELEV);
hold on;
plotHandle2 = plot(xTop,yTop,'b');
plotHandle3 = plot(xBottom,yBottom,'b');
plotHandle4 = plot(xLeft,yLeft,'b');
plotHandle5 = plot(xRight,yRight,'b');
hold off;

Then I try to re-plot it after doing some operations on the variables/vectors and this is where it breaks down:

subplot(2,1,1);
set(plotHandle,'XData',xMeters(xStart:xEnd));
set(plotHandle,'YData',yMeters(yStart:yEnd));
set(plotHandle,'ZData',ELEV(yStart:yEnd,xStart:xEnd));
subplot(2,1,2);
set(plotHandle2,'XData',xTop);
set(plotHandle2,'YData',yTop);
set(plotHandle3,'XData',xBottom);
set(plotHandle3,'YData',yBottom);
set(plotHandle4,'XData',xLeft);
set(plotHandle4,'YData',yLeft);
set(plotHandle5,'XData',xRight);
set(plotHandle5,'YData',yRight);

drawnow;

Can anyone please help?

当您不使用mex或其他外部接口时,Matlab崩溃是联系Mathworks客户支持的一种情况。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM