1 view (last 30 days)

Show older comments

function[PacksA,PacksB,ContA,ContB,AR,BR,fA,fB]=OutAR_NotOutBR(i,Max,AR,BR,fB,fA,ContB)

if AR<Max

%PacksB, PacksA, ContB, ContA are vectors that vary according to the operation

PacksB=3; fB=fB+1;

PacksA=2; ContA(AR+1)=i; AR=AR+1;

if BR==1

PacksB(ContB(1))=4; fB=fB+1;

ContB(1)=0; BR=BR-1;

elseif BR>=2

PacksB(ContB(1,1:2))=4; fB=fB+2;

if BR==2

ContB=0;

else

ContB(1)=ContB(3); ContB(1,2:3)=0;

end

BR=BR-2;

end

elseif AR==Max

PacksA=3; fA=fA+1;

PacksB=3; fB=fB+1;

if BR>0

PacksB(ContB)=4; fB=fB+BR;

ContB=0;

BR=0;

end

%Hi. What's up? Is there someone here who can help me with this error?

%Error in ==> OutAR_NotOutBR at 2 %if AR<Max

Geoff Hayes
on 18 Nov 2020

Fidele - since your function signature is

function [a,b,c] = trial_function(num)

then you need to assign values to each of the three output variables which you are not currently doing

if num==2

a=10;

b=5

elseif num==4 % <---- note this should be elseif rather than else if

c=100;

end

The easiest solution is to just assign default values to these three variables as

a = 0;

b = 0;

c = 0;

if num==2

a=10;

b=5

elseif num==4 % <---- note this should be elseif rather than else if

c=100;

end

But is the above code really what you want? Do you want to assign different values to a and b and c if num is 2 or 4 or any other integer?

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

Start Hunting!