フィルターのクリア

How to add data in a matrice?

1 回表示 (過去 30 日間)
Philipp Mueller
Philipp Mueller 2016 年 9 月 12 日
コメント済み: Philipp Mueller 2016 年 9 月 12 日
I have just one input parameter: "Number of rows" How can i create such a matrice with 4 columns and this input data "1,2,3,4;5,6,7,8;9,10..... With a for loop?
F = [1,2,3,4;5,6,7,8;9,10,11,12;13,14,15,16;17,18,19,20;21,22,23,24;25,26,27,28;29,30,31,32];
thank you so much

採用された回答

Andrei Bobrov
Andrei Bobrov 2016 年 9 月 12 日
without loop:
F = reshape(1:32,4,[])';
  1 件のコメント
Philipp Mueller
Philipp Mueller 2016 年 9 月 12 日
thx exactly that what i want

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

その他の回答 (1 件)

KSSV
KSSV 2016 年 9 月 12 日
編集済み: KSSV 2016 年 9 月 12 日
Why you want to use a loop? you can do it in a single stretch.
if rows are known:
rows = 8 ;
data = 1:32 ;
F = reshape(data,[],rows)' ;
If columns are known
col = 4 ;
data = 1:32 ;
F = reshape(data,col,[])' ;
Note that while converting data into a matrix, the number of elements must not change.
  1 件のコメント
Philipp Mueller
Philipp Mueller 2016 年 9 月 12 日
thx i understand

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

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by