How do I create a matrix with three variables?
44 ビュー (過去 30 日間)
古いコメントを表示
I need to create a function for creating a matrix with three variables: the width, the height and one filler between 0 and 9, with the values of the width and the height in an extra column and an extra row. For example be the function matrix(7,9,2) would return me something like this image:
How can I do that?
0 件のコメント
回答 (1 件)
Sean de Wolski
2015 年 4 月 13 日
With simple indexing:
w = 7; % width
h = 9; % height
f = randi(9,1); % random
M = [0 1:w; (1:h).' repmat(f,h,w)]
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!