implicit and non linear equation by using fsolve

6 visualizzazioni (ultimi 30 giorni)
Hello
I have the following program please help me
syms R L C
R=50;
L=150e-6;
C=47e-6;
zeta=1/(2*R)*sqrt(L/C);
w=1/sqrt(L*C);
alpha1=1/(2*R*C);
T=10e-6;
alpha=exp(-alpha1*T);
A=alpha1/w*sqrt(1-zeta^2);
b=w*sqrt(1-zeta^2);
%equ1='0.004236=2*A*alpha*sin(b*T)';
%equ2='-1.982=2*alpha*cos(b*T)';
%equ3='0.9958=alpha^2';
sol=solve('(2*A*alpha*sin(b*T)=0.004236)','(2*alpha*cos(b*T)=-1.982)','(alpha^2=0.9958)') % i want to find the value of R,L and C
%eq1=(-2*exp(-1/(2*R*C)*T)*cos(1/sqrt(L*C)*sqrt(1-1/(2*R)*sqrt(L/C)^2)*T))+1.982;
%eq2=1/(2*R*C)/1/sqrt(L*C)*sqrt(1-1/(2*R)*sqrt(L/C)^2)*exp(-1/(2*R*C)*T)*sin(1/sqrt(L*C)*sqrt(1-1/(2*R)*sqrt(L/C)^2)*T)-0.00423;
%eq3=(exp(-1/(2*R*C)*T)^2-0.9958);
%sol=solve('(-2*exp(-1/(2*R*C)*T)*cos(1/sqrt(L*C)*sqrt(1-1/(2*R)*sqrt(L/C)^2)*T))+1.982','(exp(-1/(2*R*C)*T)^2-0.9958)','1/(2*R*C)/1/sqrt(L*C)*sqrt(1-1/(2*R)*sqrt(L/C)^2)*exp(-1/(2*R*C)*T)*sin(1/sqrt(L*C)*sqrt(1-1/(2*R)*sqrt(L/C)^2)*T)-0.00423');
RSol = sol.R
LSol = sol.L
CSol = sol.C
I tried to write the equation in every way as you can also look with the comment equations.
which mistake i'm making here i don't know
i'm not good in Matlab if someone has some hint then please share with me I also used fsolve for this
function F = myfun1(x)
syms R L C
zeta=1/(2*R)*sqrt(L/C);
w=1/sqrt(L*C);
alpha1=1/(2*R*C);
T=10e-6;
alpha=exp(-alpha1*T);
A=alpha1/w*sqrt(1-zeta^2);
b=w*sqrt(1-zeta^2);
F = F=[(2*A*alpha*sin(b*T)-0.004236);(2*alpha*cos(b*T)+1.982);alpha^2-0.9958;];
%F=[1/(2*R*C)/1/sqrt(L*C)*sqrt(1-1/(2*R)*sqrt(L/C)^2)*exp(-1/(2*R*C)*T)*sin(1/sqrt(L*C)*sqrt(1-1/(2*R)*sqrt(L/C)^2)*T)-0.004236;
%-2*exp(-1/(2*R*C)*T)*cos(1/sqrt(L*C)*sqrt(1-1/(2*R)*sqrt(L/C)^2)*T)+1.982;
%exp(-1/(2*R*C)*T)^2-0.9958;]
end
but when i call it by giving the exact value of R,L and C then it's not showing the correct result like
x0 = [50 150e-6 47e-6]; % Make a starting guess at the solution
[x,fval] = fsolve(@myfun1,x0)
Please tell me how can i find the value of R L and C explicitly.
Thank you so much
  1 Commento
Matt J
Matt J il 15 Dic 2015
Modificato: Matt J il 15 Dic 2015
I also used fsolve for this ... but when i call it by giving the exact value of R,L and C then it's not showing the correct result
The code you've shown does not run. It would have given you the error message,
The expression to the left of the equals sign is not a valid target for an assignment.
In any case, if the known solution does not solve the equations that means myfun1 does not contain the correct equations.

Accedi per commentare.

Risposte (2)

Walter Roberson
Walter Roberson il 15 Dic 2015
Do not assign numeric values to R, L, and C after you use "syms": that overwrites their identity as symbolic variables and leaves you with numeric expressions to solve instead of symbolic expressions.
The equations are inconsistent. You can make a substitution of variables to reduce R*C to a single variable, solve the third equation to get a value for it, and substitute that into the second equation. You can then make a substitution of variables to reduce L*C to a single variable and solve the second equation for that. When you then substitute those two values (the one for R*C and the one for L*C) in to the first equation, you will find that the first equation becomes entirely numeric and it does not balance, not by a factor of about 40.
  5 Commenti
Ali Imran Siddiqui
Ali Imran Siddiqui il 16 Dic 2015
@Walter Roberson Thank you so much I also admit this fact only ratio are possible and it's impossible to solve equation for R,L and C independently
Ali Imran Siddiqui
Ali Imran Siddiqui il 21 Dic 2015
@Walter Roberson is it possible to make these equations linear? Then the solution is possible.

Accedi per commentare.


Matt J
Matt J il 15 Dic 2015
One of the problems with myfun1(x) is that it is not using the input argument x in any way. Presumably the first few lines of the function should look like
function F = myfun1(x)
R=x(1);
L=x(2);
C=x(3);
The line
syms R L C
does not belong here. You are not doing anything symbolic when using fsolve.
  1 Commento
Ali Imran Siddiqui
Ali Imran Siddiqui il 16 Dic 2015
Mr Matt J. Thank you i have already tried by assigning X value to R,La and C

Accedi per commentare.

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by