0
votes

I am trying to create a 75000*75000 identity matrix in Matlab with the code:

sparse(eye(75000))

and I get the following error:

Requested 75000x75000 (41.9GB) array exceeds maximum array size preference. Creation of arrays
greater than this limit may take a long time and cause MATLAB to become unresponsive. See array
size limit or preference panel for more information.

I know the reason for the error, but but how can I create such a sparse matrix in Matlab?

1
speye is the third result from the documentation... - excaza
Thanks. I will accept your answer if you provide it. - CoderInNetwork

1 Answers

2
votes
sparse(eye(75000));

Requires eye(75000) be stored in memory. You want to use speye to avoid the intermediate step:

speye(75000);

I'd also recommend reading the documentation for Sparse Matrix Creation.