I have written a code for my final year project . I called a crn(). I get a error that too many arguments. but when I run the function code alone, I get the output with single argument.
function crn(tow)Q =20;Pi=[0.3,0.4,0.2,0.5,0.4];Pa=10;%tow=0.5
Pdbar=15;Y=4;fs=10000;yi=[1,3,5,2,3];y1=[1,2,5,8,7];y2=10;yj=[2,3,4,5,2];N=5;z=sum(Pi(2:N).*yi(2:N));S=(Pa*y2)/(1+z);alpha=sqrt((2*Y)+1)*Q^-1*Pdbar;a=sum(Pi(2:N).*y1(2:N));yj=yj(3:N);yj=[yj 0];b=sum(Pi(2:N).*yj);bet=sum(log2((1+(sum(Pi(2:N).*yi(2:N))/(1+b)))))-(a/(1+a));A = ((1-(Q*(alpha+(sqrt(tow*fs)*Y))))+((1-tow)*((Y*sqrt(fs))/(2*sqrt(2*3.14)))*tow^(-0.5)*exp(-(alpha+(sqrt(tow*fs)*Y))^2)/2));B = (log2(1+((tow*S)/(1-tow)))+((1-tow)*(1-(Q*(alpha+(sqrt(tow*fs)*Y))))*(S/(((bet+1)*(1-tow))+(S*tow))*(1-tow))));dR_tow=((A*B*10^(-7))/3);%disp(dR_tow);
end
T=1;tow_min=0;tow_max=T;while (tow_max-tow_min)>0.02 tow_bar=(tow_max+tow_min)/2; a=crn(tow_bar); b=crn(tow_min); if a==b tow_min=tow_bar; else tow_max=tow_bar; endendtow0=tow_bar;disp("tow0="+tow);
Best Answer