Need help creating matrix (Easy)

A 5x7 matrix where each value is given by 'number of row x number of colon'
This is the matrix I want to create [1 2 3 4 5 6 7 2 4 6 8 10 12 14 3 6 9 12 15 18 21 4 8 12 16 20 24 28 5 10 15 20 25 30 35]
First off, I am completely new to this. I tried to go about it in one step, by creating two for loops; however, I am stuck because the values do not grow by the same amount for rows/columns.
Any help is greatly appreciated!

 採用された回答

Image Analyst
Image Analyst 2014 年 9 月 20 日

0 投票

Try this:
for column = 1 : 7
for row = 1 : 5
result(row, column) = row * column;
end
end
% Print to command window:
result

1 件のコメント

Ulrik
Ulrik 2014 年 9 月 22 日
Thanks a lot

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

その他の回答 (2 件)

Matt J
Matt J 2014 年 9 月 20 日
編集済み: Matt J 2014 年 9 月 20 日

0 投票

Hint,
result=randi(10,10,1)*(1:3);
Roger Stafford
Roger Stafford 2014 年 9 月 21 日

0 投票

M = reshape((1:7)'*(1:5),1,[]);

カテゴリ

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

質問済み:

2014 年 9 月 20 日

コメント済み:

2014 年 9 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by