cftool remove original data from fitted result

조회 수: 8 (최근 30일)
helloqxn
helloqxn 2017년 1월 13일
답변: helloqxn 2017년 1월 13일
Hi,
Does anyone know how to remove original data points from the cftool fitting result? (those black spots make the graph ugly.)
Thanks, X

답변 (2개)

halleyhit
halleyhit 2017년 1월 13일
편집: halleyhit 2017년 1월 13일
1. fit->save to workspace, choose save fit to matlab object named fit1, for example. 2. In command window, plot(x,fit1(x)). Here assume x is the X data in cftool.
  댓글 수: 2
helloqxn
helloqxn 2017년 1월 13일
Hi Halleyhit,
What if I am using x y z data to fit a surface? I tried to do as you said, but I find in "fit1" there is no matrix which can be used to plot "surf" in command window.
X
halleyhit
halleyhit 2017년 1월 13일
편집: halleyhit 2017년 1월 13일
if true
x1=linspace(min(x),max(x),10);
y1=linspace(min(y),max(y),10);
surf(x1,y1,fit1(x1,y1))
end
You may try this code. Here x and y are X data and Y data in cftool. x1 and y1 are the range of surf and you can adjust them. surf or surface can be used to show the image.

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


helloqxn
helloqxn 2017년 1월 13일
I found a way I think it meets my requirement: cftool->file->generate code. Then modify the code a bit: in plot fit with data session, keep only "fitresult" in plot command.
if true
% Plot fit with data.
figure( 'Name', 'untitled fit 1' );
h = plot( fitresult, [xData, yData], zData );
legend( h, 'untitled fit 1', 'v vs. x, y', 'Location', 'NorthEast' );
% Label axes
xlabel x
ylabel y
zlabel v
grid on
end
Change it to be:
if true
% Plot fit with data.
figure( 'Name', 'untitled fit 1' );
h = plot(fitresult);
legend( h, 'untitled fit 1', 'v vs. x, y', 'Location', 'NorthEast' );
% Label axes
xlabel x
ylabel y
zlabel v
grid on
end

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by