faqts : Computers : Programming : Languages : Matlab : Matrices

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

4 of 6 people (67%) answered Yes
Recently 4 of 5 people (80%) answered Yes

Entry

How do I create a large matrix with copies of the value A?
How should I initialise a very large matrix containing a single value?

Jun 7th, 2001 04:55
Per M Knutsen,


When the value is not zero or one, use the repmat function. repmat is 
faster (and more convenient) than other solutions, such as A*ones(M,N), 
especially when M and N are very large. If the value you want to put 
into the matrix, you may use the ones or zeros function instead.
Example:
>> repmat(1,2,2)
ans =
     1     1
     1     1