How to convert big sparse symbolic matrix to function handle using matlabFunction in R2013a

3 views (last 30 days)
Hi everybody,
I am importing from another program matrices defined in a text file to Matlab.
The symbolic matrices are initialised in Matlab with zeros:
M = sym(zeros(dim_matrix));
All symbolic variables are defined:
x = sym('x', [2 1]);
Then I run the text file with the matrix description:
run('file_matrix.m')
In the text file, only non-zero elements of the matrix are defined:
M(123,4) = x1^2 + x2^2;
Then, a function handle, that is stored in a structure, will be created:
S.fhd = matlabFunction(M,'vars',{x});
There is the following problem now: For matrices that are "relatively" big (couple of hundrets of columns or rows) the matlabFunction takes a lot of time even in cases where there are only zero elements of the matrix M. The option
matlabFunction('Sparse',true)
is not implemented in R2013a.
Do you have any suggestions to skip somehow the zero-elements when creating the function handle? Ideally, the function handle should give a full matrix when being called.
Many thanks in advance!

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!