Error: Too many output arguments
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Barry Allen
am 25 Feb. 2020
Bearbeitet: Stephen23
am 25 Feb. 2020
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;
end
end
tow0=tow_bar;
disp("tow0="+tow);
1 Kommentar
Akzeptierte Antwort
Subhadeep Koley
am 25 Feb. 2020
Hi, this is because you function crn is not returning anything. If you want to return dR_tow then use the code below.
function dR_tow = 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);
end
Hope this helps!
0 Kommentare
Weitere Antworten (1)
Andy
am 25 Feb. 2020
Assuming that the information you want to return is dR_tow, change the first line of the function to
function [dR_tow] = crn(tow)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Direct Search finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!