MATLAB trouble with reshape and random matricies

Click For Summary
SUMMARY

The discussion focuses on solving specific MATLAB assignment problems involving matrix manipulation. The user successfully created a 10x10 matrix, cMat, using the reshape function with a linear space from 1 to 100. For the second task, they generated a 5x3 matrix, fMat, of random integers ranging from -3 to 3 using the rand function combined with ceil. The solutions demonstrate effective use of MATLAB's matrix functions for educational purposes.

PREREQUISITES
  • Familiarity with MATLAB syntax and environment
  • Understanding of matrix dimensions and reshaping
  • Knowledge of random number generation in MATLAB
  • Basic concepts of linear indexing in MATLAB
NEXT STEPS
  • Explore MATLAB's reshape function in detail
  • Learn about generating random numbers using rand and randi
  • Investigate the use of linspace for creating vectors
  • Study advanced matrix operations and manipulations in MATLAB
USEFUL FOR

Students learning MATLAB, educators teaching programming concepts, and anyone looking to enhance their skills in matrix operations and random number generation in MATLAB.

JonDrew
Messages
64
Reaction score
0
I am trying to learn MATLAB with MIT OCW and I am running into some trouble.

It says as an assignment:

c. cMat = a 10x10 matrix where the vector 1:100 runs down the columns (use reshape).

so

1 11 21...91
2....92
. .....
10...100

is the matrix I am trying to make and another exercise says

f. Make fMat be a 5x3 matrix of random integers with values on the range -3 to 3 (use rand and floor or ceil)

I am not sure how it wants me to go about these, thanks for any help. The course link is listed below.

http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-094-introduction-to-matlab-january-iap-2010/index.htm
 
Physics news on Phys.org
Figured it out. It took me a while though, sadly.

for c. I used

cMat= linspace(1, 100)
cMat= reshape(cMat,10, 10)

and d. I used

fMat= ceil(rand(5,3)*10);
mod(fMat, 4)

And I really appreciate the help I am learning it through the MIT slides alone, I find I get hung up on little things like this.
 

Similar threads

Replies
3
Views
29K