How to find critical points of equations in Matlab?
In Matlab, we use meshgrid
a double for loop instead to increase speed, especially when the number of iterations is large.
In my application I am using meshgrid
matrix to find the critical point.
syms x a=0.1:5 b=0.1:5 [A,B]=meshgrid(a,b) y=A*x^2+B*x+B y_deriv=diff(y,x) solution=solve(y_deriv==0,x)
However, this gives me
Warning: 25 equations in 1 variables.
> In C:\Program Files\MATLAB\R2013b\toolbox\symbolic\symbolic\symengine.p>symengine at 56
In mupadengine.mupadengine>mupadengine.evalin at 97
In mupadengine.mupadengine>mupadengine.feval at 150
In solve at 170
Warning: Explicit solution could not be found.
> In solve at 179
solution =
[ empty sym ]
What I wanted to do was:
solve(y_deriv(1)==0,x)
and
solve(y_deriv(2)==0,x)
... etc.
I could do it in a loop, but I don't want to. Is there any step by step solution for a sane solution in Matlab?
Update:
I think y_deriv
gives me:
[ x/5 + 1/10, (11*x)/5 + 1/10, (21*x)/5 + 1/10, (31*x)/5 + 1/10, (41*x)/5 + 1/10]
[ x/5 + 11/10, (11*x)/5 + 11/10, (21*x)/5 + 11/10, (31*x)/5 + 11/10, (41*x)/5 + 11/10]
[ x/5 + 21/10, (11*x)/5 + 21/10, (21*x)/5 + 21/10, (31*x)/5 + 21/10, (41*x)/5 + 21/10]
[ x/5 + 31/10, (11*x)/5 + 31/10, (21*x)/5 + 31/10, (31*x)/5 + 31/10, (41*x)/5 + 31/10]
[ x/5 + 41/10, (11*x)/5 + 41/10, (21*x)/5 + 41/10, (31*x)/5 + 41/10, (41*x)/5 + 41/10]
I want to solve the x/5+1/10==0
, x/5+11/10==0
, x/5+21/10==0
, and etc ... for all elements in the matrix.
source to share
No one has answered this question yet
Check out similar questions: