Creating a 2D Matrix based on variables

Hi
I am looking to create a 2D Matrix based on three variables, A,B and C. A which could be between 8 and 12, B which could be between 4 and 50 and C which could be between 3 and 5. I need to matrix to be automatically constructed based on the variables, for example when A=10, B=7 and C=3
Matrix =
10 10 10 10 10 10 10
10 10 10 10 10 10 10
10 10 10 10 10 10 10
So I need A to control the values in the Matrix, B to control the number of columns and C to control the number of rows.
If anyone knows of a solution it would be much appreciated
Thankyou
Andy

 採用された回答

Jan
Jan 2012 年 4 月 27 日

2 投票

A = 10;
B = 7;
C = 3;
Matrix = repmat(A, C, B);
Or:
clear('Matrix');
Matrix(1:C, 1:B) = A;
Or:
Matrix = A(ones(C, B));

1 件のコメント

Andrei Bobrov
Andrei Bobrov 2012 年 4 月 27 日
Hi Jan!
Matrix = A*ones(C, B);

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

その他の回答 (1 件)

Andy
Andy 2012 年 4 月 27 日

0 投票

Problem is solved, Thankyou very much for your replies! Much appreciated
Andy

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

タグ

質問済み:

2012 年 4 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by