MATLAB: Error using fzero (line 306) FZERO cannot continue because user-supplied function_handle ==> @(x)((x(i)​/gemmai(i)​)*(exp(D(i​)/x(i))-1)​+x(i)-C(i)​) failed with the error below. Index exceeds array bounds. Error in abc (line 6) y=fzero(fun,12);

mathematicsMATLABsignal processing

i am trying to solve this very simple code but facing the above error. can any body please help me?
gemmai=[2.188410605019781 0.024184639877264 3.377571120311852 0.010142425294078];
D=[1 1 1 1];
C=[1.033272967809139 0.390745943499492 0.078198616964645];
for i=3:-1:1
fun=@(x)((x(i)/gemmai(i))*(exp(D(i)/x(i))-1)+x(i)-C(i));
y=fzero(fun,12);
end

Best Answer

fun=@(x)((x/gemmai(i))*(exp(D(i)/x)-1)+x-C(i));
Related Question