How to use multiple outputs from function
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Etan Cole
el 18 de Nov. de 2014
Comentada: Matt J
el 18 de Nov. de 2014
function[x,y]=rowcolum(a,b)
x=max(sum(a,2));
y=min(sum(b,1));
end
how to write a code that will sum x+y in main script?
0 comentarios
Respuesta aceptada
Más respuestas (1)
Matt J
el 18 de Nov. de 2014
Editada: Matt J
el 18 de Nov. de 2014
I assume you want to do the summation outside the workspace, for some reason . If so, then,
outputsRequested=2;
[c{1:outputsRequested}]=rowcolumn(a,b);
result = sum([c{:}])
2 comentarios
Matt J
el 18 de Nov. de 2014
You can later assign the output to separate variables if you wish,
x=c{1}
y=c{2}
but why you wouldn't simply use c{1} and c{2} instead of separate variables x and y is not clear.
Ver también
Categorías
Más información sobre Cell Arrays 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!