shanty February 2016

Undefined function 'sparse' for input arguments of type 'sym'. (Matlab)

I'm trying to create a sparse matrix that has non-numeric elements.

syms a b c;

i = [1 1 2 2];
j = [1 2 1 2];
s = [a b 3 c];

sparse(i,j,s,2,2)

which returns this error:

Undefined function 'sparse' for input arguments of type 'sym'.

Error in Test2 (line 8)
sparse(i,j,s,2,2)

Answers


Marc February 2016

It's pretty simple: Matlab has no function sparse() that takes symbolic variables as arguments. (s is your problem) The only sparse() function takes just numeric elements.


horchler February 2016

As I stated in the comments, there is no such thing as a sparse symbolic matrix in Matlab. This is stated in the documentation for the third input argument for the form of sparse you're using:

v — Values
scalar | vector | matrix

...

Data Types: double | logical

Matlab's Symbolic Math (and MuPAD) may take advantage of inherent sparsity internally (for storage and computation).

Post Status

Asked in February 2016
Viewed 2,926 times
Voted 7
Answered 2 times

Search




Leave an answer