Hello, I've got a code that solves pde system. As a result I've got matrix with values in different points (coordinate and time layer). Now I'm trying to plot the surface like this
figure
[x1,y1]=meshgrid(time,x);
surf(x1,y1,u(:,:),'EdgeColor','black');
colormap(copper)
set(gca,'linewidth',2)
shading interp;
grid on;
hold on;
where x and time are vectors of coordinate and time points, u is the result matrix. But the surface looks very strange.
How can I add the lines on this surface? Like this

 채택된 답변

Mischa Kim
Mischa Kim 2014년 4월 10일

0 개 추천

Danila, remove
shading interp;

댓글 수: 6

Mischa Kim
Mischa Kim 2014년 4월 10일
편집: Mischa Kim 2014년 4월 10일
Very interesting. Could you attach your data ( x,time,u ) as a .mat file? Also, for better readability, please add comments as comments, not answers.
Danila Zharenkov
Danila Zharenkov 2014년 4월 10일
Here is my .m file with code. x and time are the vectors of grid points for PDE solution.
Mischa Kim
Mischa Kim 2014년 4월 10일
It's the huge number of data points that make the surface mesh lines turn the entire plot black. You can see the effect when reducing m and tmax.
So what you should be able to do, is to plot on top of your original plot an extra surface mesh (using the hold command) with a reduced number of data points.
Danila Zharenkov
Danila Zharenkov 2014년 4월 10일
You are right, with reduced number of data points it works.
Do you mean that I should solve this system second time with reduced number of points and plot it on the first surface?
Mischa Kim
Mischa Kim 2014년 4월 11일
편집: Mischa Kim 2014년 4월 11일
Or simply down-sample the matrices. Would this work:
figure;
[x1,y1] = meshgrid(time,x);
xsam = 1:5:size(x1,1); % the 5 sets the lines spacing
ysam = 1:3000:size(x1,2);
surf(x1(xsam,ysam),y1(xsam,ysam),u(xsam,ysam),'EdgeColor','black');
colormap(copper);
You still got all the data (for analysis), for visualization the down-sampled plot should be sufficient.
Danila Zharenkov
Danila Zharenkov 2014년 4월 12일
Thanks! That works.

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

추가 답변 (2개)

Danila Zharenkov
Danila Zharenkov 2014년 4월 10일

0 개 추천

I was trying to remove shading. Here's the result
It's funny, I can't understand what going on with this plot.

댓글 수: 1

Mischa Kim
Mischa Kim 2014년 4월 10일
Please add comments as comments, not answers.

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

Kelly Kearney
Kelly Kearney 2014년 4월 10일

0 개 추천

The wireframe function will give the effect you're looking for:
[x,y,z] = peaks(500);
surf(x,y,z);
shading flat;
wireframe(x,y,z,20);

카테고리

질문:

2014년 4월 10일

댓글:

2014년 4월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by