(adsbygoogle = window.adsbygoogle || []).push({}); Matlab "solve" function in "for" loops

I need to solve a similar problem like shown in the below codes for a larger matrix,

The 'x' here needs to be solved for each y(a,b). Each of this y(a,b) is equal to zero and 'x' will vary accordingly , so it will give a 2by 2 matrix for 'x' as well.

syms x;

y = [sin(x)+5 3*cos(x)-4

cos(x)-1 cos(x)-0.6];

C=zeros(2,2);

for a=1:2

for b=1:2

B(a,b)= solve('y(a,b)=0',x);

%B(a,b)=solve('y(a,b)=C(a,b)',x);

end

end

When I try to solve it without the loop it gives the following error,

(Warning: 4 equations in 1 variables.

Warning: Explicit solution could not be found.

> In solve at 81)

When I try with the loop it gives me the following error,

??? Error using ==> mupadmex

Error in MuPAD command: Invalid index

- ;

during evaluation of 'matchNonSingletonLHS'

Error in ==> sym.sym>sym.subsasgn at 1420

C = mupadmex('mllib::subsasgn',A.s,B.s,inds{:});

It will be great if someone can give me a clue to solve this problem.

**Physics Forums - The Fusion of Science and Community**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Matlab solve function in for loops

Loading...

Similar Threads - Matlab solve function | Date |
---|---|

Matlab Solving equation with integration using MATLAB | Aug 4, 2017 |

Solve Riccati (DARE) with MATLAB | Sep 14, 2016 |

Too little appearance of symbols and numbers in matlab [Solved] | Jun 10, 2016 |

Matlab ODE45: solving with coefficients that are functions of time | Aug 5, 2011 |

How to use solve function in matlab in this case | Oct 26, 2007 |

**Physics Forums - The Fusion of Science and Community**