Problem to export fitting result to the other function.

I am trying to create curves from the same equation but different coefficient, so to load multiple data I have this created by my labmate
c1= data(:,1); n1 = data(:,3);
c2= data(:,2); n2 = data(:,4);
n =size(data,1);
tsParams = zeros(n,2);
for i=1:n
tsParams(i,:) = testsolver([c1(i), c2(i), n1(i), n2(i)])';
end
xlswrite(fullfile(pn,strcat('twostate_',fn)),tsParams);
end
Then I created the other function testsolver:
function x = testsolver(inVec, varargin)
c1 = inVec(1); n1 = inVec(3);
c2 = inVec(2); n2 = inVec(4);
x0 = [0.5; 8]; %starting guess
m=(0:0.1:3)
y =((m/c2).^n2)./(1+(m/c1).^n1+(m/c2).^n2);%create a curve
myfittype = fittype('(m.^n )/(Cm.^n+m.^n)',...
'dependent',{'y'},'independent',{'m'},...
'coefficients',{'Cm','n'});
% fit to f(C) = (C)^n /(Cm^n+C^n)
x = fit(m',y',myfittype,'StartPoint',x0) %seems like here I have problem here?
end
But it does not go through. The system gives me only the fitting result for the first row and this error message:
The following error occurred converting from cfit to double: Error using double Conversion to double from cfit is not possible. Error in btstrpTwoStateConvert_test (line 20) tsParams(i,:) = untitled2([c1(i), c2(i), n1(i), n2(i)])';
Can someone tell me what went wrong?

Respuestas (0)

Categorías

Más información sobre Linear and Nonlinear Regression en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 7 de Nov. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by