Borrar filtros
Borrar filtros

Getting multiple outputs in one time

1 visualización (últimos 30 días)
Sharanya
Sharanya el 12 de Dic. de 2022
Respondida: Torsten el 12 de Dic. de 2022
I have a function stiff(k), which outputs a matrix. I want to output stiff(k) for k=1 to 20, but I'm only able to do it by writing out each individul k value. Is there more efficient way to do this?

Respuestas (1)

Torsten
Torsten el 12 de Dic. de 2022
A = arrayfun(@(k)stiff(k),1:20,'UniformOutput',0)
A = 1×20 cell array
{2×3 double} {2×3 double} {2×3 double} {2×3 double} {2×3 double} {2×3 double} {2×3 double} {2×3 double} {2×3 double} {2×3 double} {2×3 double} {2×3 double} {2×3 double} {2×3 double} {2×3 double} {2×3 double} {2×3 double} {2×3 double} {2×3 double} {2×3 double}
function out = stiff(k)
out = k*[1 2 3;4 5 6];
end

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by