Computing the Jacobian of vectorized ODEs in MATLAB -
this works fine:
syms b x jacobian ([a*x - a*b, a*b],[a, b])
but this:
syms b(i) x = 1:6 jacobian ([a*x - a*b(i), a*b(i)],[a, b(i)])
returns error:
error using sym/jacobian (line 37) second argument must vector of variables.
in opinion second argument is vector of variables don't understand error.
is possible differentiate respect vector of odes e.g. b(i)
? how go it?
the declaration syms b(i)
creates symbolic function b
of i
. so, if vector of doubles
passed b(i)
, output vector of function values:
>> syms b(i) >> b(1:6) ans = [ b(1), b(2), b(3), b(4), b(5), b(6)] >> b(i) = i^2; % defining actual function generate actual values >> b(1:6) ans = [ 1, 4, 9, 16, 25, 36]
so error correct: have list of values. create vector of variables, use sym
function
>> b = sym('b',[1,6]) b = [ b1, b2, b3, b4, b5, b6]
Comments
Post a Comment