matlab: matrix symbolic solution -
thanks time , help. actually, made mistake in previous post when specifying problem. thus, reformulate question using simpler example. need solve symbolically equation ct = z/(p-i) or ct*(p-i) = z.
i know answer => ct = [sigma, 1-sigma]
how program "correctly" code in order solution
syms sigma; ct = sym('ct',[1 2]); % p = [sigma 1-sigma; sigma 1-sigma]; = [1 0; 0 1]; z = [0 0]; % solve(ct*(p-i) == z); so far, :
z =
0 0
warning: solutions parametrized symbols: z = c_
in solve @ 190 in test_matrix_sigma @ 13
or
solve(ct == z/(p-i), ct); i get:
warning: system rank deficient. solution not unique. warning: 4 equations in 2 variables.
in /opt/matlab/r2013a/toolbox/symbolic/symbolic/symengine.p>symengine @ 56 in mupadengine.mupadengine>mupadengine.evalin @ 97 in mupadengine.mupadengine>mupadengine.feval @ 150 in solve @ 170 in test_matrix_sigma @ 13
--------------------------------------------------------------------------------------- thanks answer !
now have 2 issues: 1) when try handla more complicated system:
syms b p1 p2; = [1 0 0 0; 0 1 0 0; 0 0 1 0; 0 0 0 1]; % p = [a*p1 (1-a)*p1 (1-b)*(1-p1) b*(1-p1); a*p1 (1-a)*p1 (1-b)*(1-p1) b*(1-p1); b*(1-p2) (1-b)*(1-p2) (1-b)*p2 b*(1-p2); b*(1-p2) (1-b)*(1-p2) (1-b)*p2 b*(1-p2)]; % assume(a, 'real'); assume(b, 'real'); assume(p1, 'real'); assume(p2, 'real'); % answer = null((p-i)'); disp(answer); i
ans = [ empty sym ] as answer.
2) if there way in maltlab "solve" above symbolic matrix p , find symbolic determinant ?
for instance, if eid(p) works;
when det(p) gives 0 answer...
this post answer different problem, first asked op before being edited. leave problem , solution here in case ever runs same problem:
i need solve symbolically following matrix equation find out ct (a vector ???):
syms b p1 p2 % p = [a*p1 (1-a)*p1 (1-b)*(1-p1) b*(1-p1); a*p1 (1-a)*p1 (1-b)*(1-p1) b*(1-p1); b*(1-p2) (1-b)*(1-p2) (1-b)*p2 b*(1-p2); b*(1-p2) (1-b)*(1-p2) (1-b)*p2 b*(1-p2)]; % solve(ct*(p-1) == 0, ct); how proceed ?
so far get:
undefined function or variable 'ct'.
error in matrix_test (line 10) solve(ct*(p-1) == 0, ct); the error because did not assign ct before trying solve equation. in equation ct*(p-1) == 0, matlab not know ct is. remedy creating symbolic vector (see sym documentation). instance:
ct = sym('ct', [1 4]); however, using solve on not give solutions you're looking for: instead, matlab going give trivial answer ct = 0, of course correct answer equation.
what want find null space of (p-1)' matrix: null space set of vectors x such (p-1)'x = 0 (which same thing x'(p-1) = 0, ct = x'). matlab function null (see doc) need. using code, get:
null((p-1)') ans = [ -1, 0] [ 1, 0] [ 0, -1] [ 0, 1] this means linear combination of vectors [-1, 1, 0, 0] , [0, 0, -1, 1] belong null space of (p-1)', , therefore transpose ct looking for.
n.b.: result confirmed observation of initial matrix p.
Comments
Post a Comment