필터 지우기
필터 지우기

How to save output in array

조회 수: 10 (최근 30일)
Emily
Emily 2022년 5월 31일
답변: Voss 2022년 5월 31일
Hi, I'm trying to create a loop that prints the output in an array and not sure how to save/print as I want.
num=5;
for k=1:num
a=k^2;
num=num+1;
end
output=[a(1), a(2), a(3), a(4), a(5)]

채택된 답변

Voss
Voss 2022년 5월 31일
Like this?
num = 5;
for k = 1:num
a(k) = k^2;
end
disp(a)
1 4 9 16 25

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by