Solve always returns 0x1 sym results for a non linear system of equations, symbolic toolbox
10 次查看(过去 30 天)
显示 更早的评论
Hi!
Can someone help me out with this please? I try to solve this nonlinear system of equations but solve always give me a 0x1 sym result for all the unknown parameters (A,I,V,alfa, gamma, fi)! I have also tried to use vpasolve but it gives me the same results!
I am using MATLAB R2017a!
Thanks in advance!
clear all
clc
n=1;
r=0.1;
A0=r^2*pi;
I0=(2*r)^4*pi/64;
ro=2700;
E=210*10^9;
w=100;
l=1;
syms x
V = sym('V', [1 n]);
I = sym('I', [1 n]);
A = sym('A', [1 n]);
fi= sym('fi', [1 n]);
gamma=sym('gamma', [1 n]);
alfa=sym('alfa', [1 n]);
for oszlop=1:n
vvektor(oszlop)=V(oszlop)*exp(1j*oszlop*x/l+fi(oszlop));
Ivektor(oszlop)=I(oszlop)*exp(1j*oszlop*x/l+gamma(oszlop));
Avektor(oszlop)=A(oszlop)*exp(1j*oszlop*x/l+alfa(oszlop));
end
v=sum(vvektor);
i2=sum(Ivektor)+I0;
a=sum(Avektor)+A0;
clear vvektror Ivektor;
baloldal=i2*diff(v,x,4)-2*diff(i2,x,1)*diff(v,x,3)+diff(i2,x,2)*diff(v,x,2);
jobboldal=ro*a*w*w/E;
xvektor=linspace(0,l,6*n);
for k=1:numel(xvektor)
baloldalvektor(k)=subs(baloldal,x,xvektor(k));
jobboldalvektor(k)=subs(jobboldal,x,xvektor(k));
end
for k=1:numel(xvektor)
eqns(k)=baloldalvektor(k)-jobboldalvektor(k)==0;
end
S=solve(eqns,A,V,I,alfa,fi,gamma,'IgnoreAnalyticConstraints', true)
0 个评论
采纳的回答
Nicolas Schmit
2017-9-4
Solve always returns 0x1 because your equations are not compatible. To demonstrate if, solve the first and second equations with respect to A.
A1 = solve(eqns(1),A);
A2 = solve(eqns(2),A);
Take the difference, and simplify the results.
diffA = simplify(A1-A2);
If you look closely at the results, you see that diffA cannot be null for a finite value of alfa. Therefore, the equations are not compatible.
There is probably a problem somewhere in your equations.
3 个评论
John D'Errico
2020-8-10
@Mohammed Ouallal - this is apparently a completely different problem. that you got a non-answer is because you are trying to solve the problem the wrong way. You need to use nonlinear regression and estimation tools. And there is no need to even use symbolic tools in this. All that does is slow your code down here. So you get no answer, AND you get that slowly.
Mohammed Ouallal
2020-8-10
That brings me back to gradient descent. The reason I tried to solve a system of equation is that my cost function does not decrease at all. I am sure that this is not the right place to discuss this. I have submitted a problem 2 or 3 days ago about Gradient descent, mini batch GD and stochastic GD. If you could look at it, I appreciate it.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!