how to get the second variable in a function?

I'm passing the value for function par it accepts two input but the function gives only one output A_output = par(20,5). How can i get the more than one output parameters?
delete(gcp);
parpool('AttachedFiles',{'par.m','par2.m'})
spmd
if labindex == 1
A_output = par(20,5);
labSend(A_output, 2);
else
B_parameters = labReceive()
B_output = par1(B_parameters)
end
end
%par.m
function[x,y] =par(x,y)
y=y+40
x=x+y
z=x+200
end
%par1.m
function[xb ,yb]= par2(yb)
yb=yb+4
xb=yb
yb=xb+20
end

댓글 수: 4

Stephen23
Stephen23 2018년 2월 26일
Very basic MATLAB concepts, such as how to get call fucntions and return their output arguments, is explained in the introductory tutorials:
These are highly recommended for all beginners, because they teach these very basic concepts which all users need to know in order to be able to use MATLAB.
DhanaLakshmiR
DhanaLakshmiR 2018년 2월 26일
편집: Stephen23 2018년 2월 26일
Function concept ok. But when simultaneously running two mfile,fetching the output from the function is little bit confusing.
dpb
dpb 2018년 2월 26일
Function concept not ok. Neither call in the code has the second return variable on LHS of the expression; ergo the function will NOT return more than the one result.
DhanaLakshmiR
DhanaLakshmiR 2018년 2월 27일
편집: DhanaLakshmiR 2018년 2월 27일
I have struggled with the very basic simple concept, now only I am cleared. Thank you all for your suggestions!

댓글을 달려면 로그인하십시오.

 채택된 답변

Torsten
Torsten 2018년 2월 26일

0 개 추천

[A_output,B_output] = par(20,5);
And name input and output variables differently in par and par2.
Best wishes
Torsten.

댓글 수: 1

eventhough,I have changed the input and output variable names different it is giving one output only.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

dpb
dpb 2018년 2월 26일

0 개 추천

[A,B] = par(20,5);
The function has to have somewhere to "put" the other output...

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2018년 2월 26일

편집:

2018년 2월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by