You are Here: Home >< Maths

# How to generate a random matrix using matlab? watch

1. How would i generate a 5x5matrix of random real numbers between the values 2 and 5.5?
2. (Original post by jlf98)
How would i generate a 5x5matrix of random real intergers between the values 2 and 5.5?
I would break this into two problems:

1. Generating a random matrix. A quick google search shows that the rand function does this. You'd want rand(5) or rand(5,5) - both are the same.

https://edoras.sdsu.edu/doc/matlab/t.../ref/rand.html

2. Getting the numbers in this to be an integer between 2 and 5.5.

The page above gives you a nice example in its explanation of the rand function, hint hint.
You'd just need one more step after you've tried this (try it, see what you get in matlab and think of how to complete the function)
3. (Original post by jlf98)
How would i generate a 5x5matrix of random real intergers between the values 2 and 5.5?
(Original post by Kevin De Bruyne)
2. Getting the numbers in this to be an integer between 2 and 5.5.
I think we need to be questioning the very concept of a random integer between 2 and 5.5. (Obviously mathematically there's no problem, but the problem statement raises eyebrows, at the very least).

### Related university courses

TSR Support Team

We have a brilliant team of more than 60 Support Team members looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

This forum is supported by:
Updated: October 23, 2017
Today on TSR

How do you think you'll do?

### University open days

Wed, 25 Jul '18
2. University of Buckingham
Wed, 25 Jul '18
3. Bournemouth University
Wed, 1 Aug '18
Poll
Useful resources

### Maths Forum posting guidelines

Not sure where to post? Read the updated guidelines here

### How to use LaTex

Writing equations the easy way

### Study habits of A* students

Top tips from students who have already aced their exams