How to fill a matrix with a range of numbers?

17 ビュー (過去 30 日間)
Vitaly
Vitaly 2013 年 4 月 17 日
Hi, it might be a silly question, but I was struggling finding an answer to that for hours.
The problem is I have a range of numbers, say k=1:10 and I have a 2x5 matrix with zeros which i want to fill with the range so that I would get a matrix like this:
A=
1 2
3 4
5 6
7 8
9 10
Number of rows and columns is given by expressions Nw+1 and Nh+1, where Nw and Nh are user's inputs.

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 4 月 17 日
A=reshape(1:10,2,[])'
  1 件のコメント
Vitaly
Vitaly 2013 年 4 月 17 日
thanks a lot

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by