matlab: subs on symbolic constant returns scalar instead of vector for a vector input

Posted by noam on Stack Overflow See other posts from Stack Overflow or by noam
Published on 2010-06-05T23:26:11Z Indexed on 2010/06/05 23:32 UTC
Read the original article Hit count: 132

Filed under:
|

usually, symbolic functions return vectors for vector inputs:

syms('x');
f=x*2;
subs(f,[1 2 3])
outputs: [2 4 6]

but doing

f=sym('0');
subs(f,[1 2 3]);
outputs: 0
and not: [0 0 0]

so basically, my questions is how do I make f behave as a "normal" symbolic function. I can do something ugly like f=x-x to create a function that always returns zero, but is there a prettier way?

© Stack Overflow or respective owner

Related posts about matlab

Related posts about symbolic