How do I specify the limits of parameters individually while fitting?

16 ビュー (過去 30 日間)
Basil Eldeeb
Basil Eldeeb 2021 年 3 月 4 日
回答済み: Nagasai Bharat 2021 年 3 月 11 日
On top of not knowing how to specifically limit 1 parameter to positive numbers, I get this error for my custom model:
Error using
fittype/testCustomModelEvaluation
(line 16)
Custom equations must produce an
output vector, matrix, or array that
is the same size and shape as the
input data. This custom equation
fails to meet that requirement:
m*exp(-d/x)*x.^2
Here is my code:
data = readmatrix('nagn125.txt');
vv=data(:,1);
ii=data(:,2);
pos=vv>0; neg=~pos;
gpos=fittype(@(m,c,d,x) m*exp(-c)*exp(-d/x)*x.^2);
options=fitoptions('exp(-d/x)','Lower',0);
plot(fneg,vv(neg),ii(neg))
grid('on')

採用された回答

Nagasai Bharat
Nagasai Bharat 2021 年 3 月 11 日
Hi,
Change the fittype statement to that of below. This should solve the error you are getting
gpos=fittype(@(m,c,d,x) m.*exp(-c).*exp(-d./x).*x.^2);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by