how to print all of output value from "for loping" function ?

1 回表示 (過去 30 日間)
ElizabethR
ElizabethR 2016 年 4 月 13 日
コメント済み: ElizabethR 2016 年 4 月 14 日
i have a code :
function f=coba1(a);
for j=1:a
f=j;
end
.....................
a=5;
b=coba1(a);
...........................
f =1
f =2
f =3
f =4
f =5
b =5
but, the variabel b only save the last value of function loop. so, how to save all of value from this looping ? thanks

採用された回答

Andrei Bobrov
Andrei Bobrov 2016 年 4 月 13 日
function f=coba1(a)
f = zeros(a,1);
for jj=1:a
f(jj)=jj;
end
or
f = (1:a).';
  1 件のコメント
ElizabethR
ElizabethR 2016 年 4 月 14 日
hi Andrei, thanks for your answare :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by