Problem with symbolic variables system
1 次查看(过去 30 天)
显示 更早的评论
I am confused with symbolic variables and function of a variable.
I have a Y which is a function of D. In fact Y is a vector of size N and each and each Yi=function(D).
I also have a X which is a function of Y. That is Xi=function(Yi) so in the end also X will be a function of D.
Then I have an A=sum(Y*X).
What I need to do is to solve a system of nonlinear equations of dA==0 where da(i)==diff(A,Y(i)) from which I will have as a solution the Y array as a function of D.
I tried this:
N=10;
Y=sym('Y',[1 N]);
X=sym('X',[1 N]);
syms D
A=0;
for i=1:N
X(i)=sqrt(D^2-Y(i)^2);
A=A+ Y(i)*X(i);
end
dA=sym('dA',[1 N]);
for i=1:N
dA(i)=diff(A,Y(i));
end
S = solve(dA==0);
But I get this: "Warning: Possibly spurious solutions. [solvelib::checkVectorSolutions]" and it is very slow.
Do you think it is a good way to solve my problem? What is the difference if I define a function dA=myfun(D)?
0 个评论
回答(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!