solve symbolic equations with unknown numbers of variables
Show older comments
Hi; I have a loop which the variables and equations are calculated in this loop and the symbolic values and numbers of them are different in each loop. Also I should solve these equations together and get some other variables which I don't know the numbers of them because the numbers are calculated in the loop. how can I use the solve command? For example if I have: z=[a+b;a-b] s=[a;b] and I don't know the size of z and s matrices, what should I do? the below command doesn't work solve(z,'s')
8 Comments
Walter Roberson
on 21 May 2012
solve(z,s) perhaps ?
frank
on 21 May 2012
Walter Roberson
on 21 May 2012
That is a correct solution to [a+b;a-b]. Add the two parts together, getting the result 2*a = 0, and thus a=0; substitute this in to [a+b] to arrive at the conclusion that b=0 as well.
frank
on 21 May 2012
Walter Roberson
on 21 May 2012
zc = mat2cell(z);
sc = mat2cell(s);
solve(zc{:}, sc{:})
frank
on 22 May 2012
Walter Roberson
on 22 May 2012
Try num2cell() instead of mat2cell()
frank
on 22 May 2012
Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!