how to create a contour for a fittype object?

1 次查看(过去 30 天)
Hi,
i've fitted a surface for a scattered data using the following commands:
load('full_data.mat')
ft = fittype( 'poly11' );
opts = fitoptions( 'Method', 'LowessFit' );
opts.Normalize = 'on';
opts.Robust = 'LAR';
[fitresult, gof] = fit( [full_data(:,1), full_data(:,2)], full_data(:,3), ft, opts );
is it possible to plot the contours for this surface after i plotted the surface itself using the next command:
plot(fitresult, [full_data(:,1), full_data(:,2)], full_data(:,3) );
thank you for your help.

采纳的回答

Mike Garrity
Mike Garrity 2015-7-8
编辑:Mike Garrity 2015-7-8
One simple way is to get the data from the surface that the plot method creates.
h = plot(fitresult, [full_data(:,1), full_data(:,2)], full_data(:,3) );
s = findobj(h,'Type','surface');
figure
contour(s.XData,s.YData,s.ZData)
The "cleaner" option would be to use the feval method. You need to pass in the XData and YData. Something like this:
load franke
T = table(x,y,z);
f = fit([T.x, T.y],T.z,'linearinterp');
[x,y]=meshgrid(linspace(500,3500,40),linspace(0,1,40));
z=feval(f,x,y);
contour(x,y,z)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Spline Postprocessing 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by