How to save values from a for loop into a matrix

I need to figure out how to store the values from this loop into a pre-initialized matrix called 'save'. I apologize if this is trivial but I am very unfamiliar with matlab.
save=zeros(4,13)
for mm=1:4
dl(mm)=fsol(iindex(mm))
end
qm=k*dl
%NEED TO STORE VALUES FROM LOOP IN 'SAVE' MATRIX
end

답변 (1개)

Jan
Jan 2021년 11월 24일
Do not use "save" as name of a variable. This would shadow an important built-in function, which causes troubles frequently.
You store the results in the variable dl. So simply use the wanted variable instead:
saved = zeros(4,13)
for mm=1:4
daved(mm, :) = fsol(iindex(mm));
end

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2021년 11월 24일

답변:

Jan
2021년 11월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by