Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Create an array with randomly selected elements

Status
Not open for further replies.

lavezlas28

Newbie level 1
Newbie level 1
Joined
Oct 9, 2014
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
11
I'm not familiar with MATLAB, and this year in our Introduction to DSP class, teacher gave us a homework but nearly none of us knows MATLAB much...

His question is;

Define a 1001-by-8 matrix, named “A”, whose elements selected randomly.
 Define an 8-by-1001 matrix, named “B”, whose elements selected randomly.
 Define a variable “C” as the multiplication of matrices “A” and “B”.
 Define a variable “D” as the mean value of the first column of “C”.
 Write the necessary code in script format.
 

I do not know Matlab. If it is anything like BASIC, then you create arrays. One-dimensional, two-dimensional, etc.

Example, variable A is a two-dimensional array. Its format is A(x,y). Maximum size is either A(1000,7) or A(7,1000).

To fill it with random numbers, a common trick is to grab from some memory location which contains a rapidly-changing value. Example, a time counter. The counter must change very rapidly, or else values will not be random.

Perhaps Matlab contains a random number function.
 


The teacher does not specify what kind of random numbers he wants in A and B. I will assume he wants random numbers drawn from the standard normal distribution. Therefore:

 Define a 1001-by-8 matrix, named “A”, whose elements selected randomly.
A = randn(1001,8);

 Define an 8-by-1001 matrix, named “B”, whose elements selected randomly.
B = randn(8,1001);

 Define a variable “C” as the multiplication of matrices “A” and “B”.
C = A*B;

 Define a variable “D” as the mean value of the first column of “C”.
D = mean(C:),1));

 Write the necessary code in script format.
This doesn't mean anything. Tell your teacher he's a lemon.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top