How to use fit matrix array

A=csvread('spotlightmtfx.txt');
h=A(:,1);
j=A(:,2);
f=fit(h, j,'gauss2')
%Coefficients
a1=1.47 %(1.426, 1.515)
b1=897.7 %(897,898.3)
c1=27.08 %(26.08 27.08)
a2=0.6994 %(0.6821, 0.7167)
b2=810.8 %(790, 831.7)
c2=592.9 %(501, 685.7)
%f=
%General model Gauss2:
f(h)=a1*exp(-((h-b1)/c1).^2)+a2*exp(-((h-b2)/c2).^2)
plot(f,h,j)
This is my code and it is not work."Cannot use cellarray brackets or parens to assign to FIT." What I have to do? Please help me. :)

댓글 수: 2

KSSV
KSSV 2017년 10월 27일
With out data, we cannot help you..attach the file....error is due to you are sending wrong class inside the fit function.
Birdman
Birdman 2017년 10월 27일
Are you trying just to plot the f model and compare the results?

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

 채택된 답변

KSSV
KSSV 2017년 10월 27일
편집: KSSV 2017년 10월 27일

0 개 추천

This line:
f(h)=a1*exp(-((h-b1)/c1).^2)+a2*exp(-((h-b2)/c2).^2)
is not correct...it should be
f = a1*exp(-((h-b1)/c1).^2)+a2*exp(-((h-b2)/c2).^2)
Below code shall work:
A=load('spotlightmtfx.txt');
h=A(:,1);
j=A(:,2);
f=fit(h, j,'gauss2')
%Coefficients
a1=1.47 %(1.426, 1.515)
b1=897.7 %(897,898.3)
c1=27.08 %(26.08 27.08)
a2=0.6994 %(0.6821, 0.7167)
b2=810.8 %(790, 831.7)
c2=592.9 %(501, 685.7)
%f=
%General model Gauss2:
f=a1*exp(-((h-b1)/c1).^2)+a2*exp(-((h-b2)/c2).^2)
plot3(f,h,j)

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

질문:

2017년 10월 27일

다시 열림:

2018년 7월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by