I'm a beginner in matlab. I have three non-linear equations
spdratio_fw = ( 1 + afw*(vc_fw)^b); spdratio_pa = ( 1 + aps*(vc_pa)^b); ind = (ddhv_fw*( 1 + afw*(vc_fw)^b) - ddhv_pa*( 1 + aps*(vc_pa)^b))/(ddhv_fw + ddhv_pa) ;
from the above three equations i have to solve for afw, aps and b.
so i wrote the commands and saved in trial.m
function F = trial(Y)
afw = Y(1);
aps = Y(2);
b = Y(3);
spdratio_fw = 1.329;
spdratio_pa = 1.168;
ind = 1.312;
vc_fw = 3.2;
vc_pa = 0.76;
ddhv_fw = 20776.82;
ddhv_pa = 2536.54;
fA = spdratio_fw - ( 1 + afw*(vc_fw)^b);
fB = spdratio_pa - ( 1 + aps*(vc_pa)^b);
fC = ind - (ddhv_fw*( 1 + afw*(vc_fw)^b) - ddhv_pa*( 1 + aps*(vc_pa)^b))/(ddhv_fw + ddhv_pa) ;
F = [fA; fB; fC];
end
and after that i ran a script
afw0 = 0.15; aps0 = 0.15; b0 = 1;
Y0 = [afw0; aps0; b0];
Y = fsolve(@trial, Y0);
result;
but the error i received:
??? Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N) to change the limit. Be aware that exceeding your available stack space can crash MATLAB and/or your computer.
Error in ==> optimget
Caused by: Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.
i gave the command :
trial
and the error is:
??? Input argument "Y" is undefined.
Error in ==> trial at 2
afw = Y(1);
I have no idea on how to fix it.