How do I create a matrix with three variables?

48 Ansichten (letzte 30 Tage)
Witu Witukas
Witu Witukas am 13 Apr. 2015
Beantwortet: Sean de Wolski am 13 Apr. 2015
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?

Antworten (1)

Sean de Wolski
Sean de Wolski am 13 Apr. 2015
With simple indexing:
w = 7; % width
h = 9; % height
f = randi(9,1); % random
M = [0 1:w; (1:h).' repmat(f,h,w)]

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by