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
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
2018 年 2 月 26 日
編集済み: Stephen23
2018 年 2 月 26 日
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
2018 年 2 月 27 日
編集済み: DhanaLakshmiR
2018 年 2 月 27 日
採用された回答
その他の回答 (1 件)
dpb
2018 年 2 月 26 日
[A,B] = par(20,5);
The function has to have somewhere to "put" the other output...
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!