Generate plot of surface colored by the maximum error

3 次查看(过去 30 天)
Hello everyone,
I am currently working on a numerical algorithm for the approximation of 3D functions ( namely f(x,y,z) ). The algorithm works fine. Following is the final result/plot:
However, I do not want the plot to be displayed like that, I would like to plot it like this:
so that I can observe the maximum error and where it is located.
I already have the plot function that generates the second image, this is however a routine for 2D functions and I can't manage to write a 3D version of it. Following is the code:
function PlotSurf(xe,ye,Pf ,neval,exact,maxerr,fview)
figure
Pfplot = surf(xe,ye,reshape(Pf,neval,neval), reshape(abs(Pf-exact),neval,neval));
set(Pfplot,'FaceColor' ,'interp','EdgeColor','none');
[cmin cmax] = caxis;
caxis([cmin-.25*maxerr cmax]);
view(fview);
colormap hsv
vcb = colorbar('vert');
ylim(vcb, [0 maxerr])
set(get(vcb,'YLabel'),'String','Error')
xe and ye being the evaluation points,
Pf the values of the numerical algorithm,
neval the number of evaluation points,
exact the exact values of the function at the evaluation points xe and ye, it is necessary in order to calculate the maximum error
maxerr maximum error
Thank you in advance.

回答(0 个)

类别

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