how to get the second variable in a function?
6 次查看(过去 30 天)
显示 更早的评论
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 个评论
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.
采纳的回答
Torsten
2018-2-26
[A_output,B_output] = par(20,5);
And name input and output variables differently in par and par2.
Best wishes
Torsten.
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 GPU Computing in MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!