Info
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
Getting error using fittype line 356?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I am using fit function to optimize two parameters but I am getting error. I created a function file named 'ytest' as
function ydata = ytest(x,k,S)
g_vecrow = (xlsread('signal1.xlsx','signal','C2:C999'))';g_vec = g_vecrow-g_vecrow(1) ;
t_vec = x.*5; dist = 45; b = 2;
for i = 2:998
t = t_vec(i);
g = g_vec(i);
tow = 0:5:t-1;
wt(i) = ((1/k*b/S)^(1/2)* dist)/(2 * sqrt(pi))* trapz(tow,g.*(t - tow).^(-3/2).*exp(-dist^2./(4*k*b/S*(t - tow))));
end
ydata = wt + 147.9;
end
where g_vecrow is vector containing 998 data points. For using fit command I am using following commands in another file
x = 1:998;
ydata = (xlsread('signal1.xlsx','signal','D2:D999'))';
ft = fittype( 'ytest( x,k,S )' );
f = fit( x, ydata, ft, 'StartPoint', [1, 0, 1, 0, 0.5] );
plot( f, x, ydata )
but I am getting following error every time I run my code. _Error using fittype (line 356) Expression ytest( x,k,S ) is not a valid MATLAB expression, has non-scalar coefficients, or cannot be evaluated: Error in fittype expression ==> ytest( x,k,S ) ??? ORDER contains an invalid permutation index.
Error in tyestexe (line 4) ft = fittype( 'ytest( x,k,S )' );_
0 Commenti
Risposte (0)
Questa domanda è chiusa.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!