store values in a zeros matrix without using for loop

Hi, I have 11 discrete values and i would like to save them in a zeros matrix i=zeros (1,11) one by one manually. I mean i perform some operations and receive the resultant in the form of those values and i would then like to save them in the matrix. There is no for loop involved, how do i do it ? Seems like all the help articles have the for loop.

5 件のコメント

dpb
dpb 2016 年 4 月 8 日
Well, what do you mean by "one by one manually"? That almost by any definition I can think of would require the loop.
Anvinder
Anvinder 2016 年 4 月 8 日
let a=2 b=5 c=3 d=9 now i have a i=zeros(1,4) matrix and i would like to put the values of a,b,c,d in the matrix such that i=[2 5 3 9]
Walter Roberson
Walter Roberson 2016 年 4 月 8 日
i(1) = a; i(2) = b; i(3) = c; i(4) = d;
dpb
dpb 2016 年 4 月 8 日
Or,
i=[a b c d ...];
But, it's probably a bad_idea(tm) to create all these variables if this is the end result; use the array or alternate way to create them to begin with so you don't have to write such code.
Stephen23
Stephen23 2016 年 4 月 8 日
Put all of the values in one variable to begin with. This will be much simpler than anything else.

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

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 4 月 8 日

0 投票

i(1) = 73.1
i(2) = 19.8
i(3) = sin(3/4)
...

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2016 年 4 月 8 日

コメント済み:

2016 年 4 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by