Getting multiple outputs in one time

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?

답변 (1개)

Torsten
Torsten 2022년 12월 12일

0 개 추천

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

카테고리

도움말 센터File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

질문:

2022년 12월 12일

답변:

2022년 12월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by