Create a 4x4 matrix with values between 1 and 10

57 views (last 30 days)
Hello! I have this problem that I've been trying to figure out. I've used the following to solve it:
A = randi([1 10],4,4):
A =
9 7 10 10
10 1 10 5
2 3 2 9
10 6 10 2
I would like to know if there's a way to solve it but having decimals included in the answer. As far as I know by using randi you will only get integers, can rand() help in this case?
Thank you so much in advance!

Answers (1)

Image Analyst
Image Analyst on 8 Oct 2021
A = 1 + 9 * rand(4,4)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!