how to get the second variable in a function?

1 visualización (últimos 30 días)
DhanaLakshmiR
DhanaLakshmiR el 26 de Feb. de 2018
Editada: DhanaLakshmiR el 27 de Feb. de 2018
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 comentarios
dpb
dpb el 26 de Feb. de 2018
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 el 27 de Feb. de 2018
Editada: DhanaLakshmiR el 27 de Feb. de 2018
I have struggled with the very basic simple concept, now only I am cleared. Thank you all for your suggestions!

Iniciar sesión para comentar.

Respuesta aceptada

Torsten
Torsten el 26 de Feb. de 2018
[A_output,B_output] = par(20,5);
And name input and output variables differently in par and par2.
Best wishes
Torsten.
  1 comentario
DhanaLakshmiR
DhanaLakshmiR el 26 de Feb. de 2018
eventhough,I have changed the input and output variable names different it is giving one output only.

Iniciar sesión para comentar.

Más respuestas (1)

dpb
dpb el 26 de Feb. de 2018
[A,B] = par(20,5);
The function has to have somewhere to "put" the other output...
  1 comentario
DhanaLakshmiR
DhanaLakshmiR el 26 de Feb. de 2018
I can't get the answer.Kindly give some explanation.

Iniciar sesión para comentar.

Categorías

Más información sobre GPU Computing in MATLAB en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by