Problem with symbolic variables system

2 visualizzazioni (ultimi 30 giorni)
xrysa
xrysa il 17 Mar 2014
Modificato: Walter Roberson il 17 Mar 2014
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)?

Risposte (0)

Categorie

Scopri di più su Symbolic Math Toolbox in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by