matlab - system of non-linear equations given in matrix form ( using fsolve) -
i trying solve system of nonlinear equations using fsolve. system given in matrix form (image), u_i being unknowns.
plz suggest how can create function given input fsolve. thanks
check out the documentation fsolve. can create function handle, either function in own file or anonymously, , call using fsolve:
h = @(u) p'*u.^2; % function handle u_next = fsolve(h, u); if doing inner product, need make sure left-hand side has same number of columns right-hand side has rows. instance, if have arbitrary 4x1 matrix p , initial 1x4 vector u, have take transposes make sure inner product works out:
p = rand(4, 1); % random column vector u = rand(1, 4); % random row vector h = @(u) p'*u'.^2; % (1x4) * (4x1) = scalar result or if trying element-wise multiplication:
h = @(u) p'.*u.^2; % (1x4) .* (1x4) = (1x4) result element-wise multiplication
Comments
Post a Comment