Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How can I resolve this equation using matlab

Status
Not open for further replies.

Foufou

Member level 5
Joined
Oct 22, 2006
Messages
93
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,288
Activity points
1,871
matlab solve equation for variable

How can I resolve this equation using matlab where
e is the unknown variable with
t0 ta and ta as known ones

eTa=1-exp(-e(t0-te)

exp denote the exponentional function
 

matlab solve equation variable

Dear friend

a = Ta;
b = T0 - Te;
x = e;


a*x = 1 - exp(-b*x);

In this equation the number of roots depends on the value of parameters a and b. If a,b>0 or a,b<0 it may have 2 roots else has one root. I think you should substitute the known value a and b in the equation, then solve it.

For example:

% a = Ta = 1
% b = T0-Te = 0.4
R = solve('1*x = 1 - exp(-0.4*x)')


Regards
 

roots of an equation using matlab

thank friend but when I try this exemple
t0=1;
te=0.55;
ta=0.04;

the solve function give me 1 root equal to 0 althougth there are 2 roots seen when we plot the functionf=x-(1/a)*(1-exp(-b*x)); (see figure atached

thanks
 

matlab roots of equation

Dear friend

% a = Ta = 0.04
% b = T0 - Te = 0.45
syms a b;
f1 = 'a*x = 1 - exp(-b*x)';
f2 = subs(f1,{a,b},{'0.04','0.45'});
R = solve(f2)


Result:
R =
[ 24.999674769963571780041109258934]
[ 0 ]


Plotting the functions a*x and 1-exp(-b*x) :

x = -1:0.001:30;
a = 0.04; b = 0.45;
plot(x,1-exp(-b*x)); grid
hold on;
plot(x,a*x,'r')




Best regards :D
 

    Foufou

    Points: 2
    Helpful Answer Positive Rating
matlab resolve

thank you very much friend

Added after 49 minutes:

Dear friend I will be verry grateful if you help me to resolve my problem explained in details in the attached doc file

Thank you for helping me
 

how to solve integrals using matlab

Dear friend

This is an M-file for CASE 1, you can change the time constants for other CASEs.
________________________________________________
clc; clear; close all;
%Parameters of Case 1:
t0 = 1;
tp = 0.41;
te = 0.55;
ta = 0.04;
tc = 0.58;
% ******************************************
% Finding e: { e*ta = 1 - exp(-e*(tc-te)) }
syms e;
f = e*ta - 1 + exp(-e*(tc-te));
R_e = numeric(solve(f));
E = R_e(1) + R_e(2) % E = nonzero root of f (one root is zero)
% ******************************************
% Finding alpha = x:
k1 = (pi/tp)^2;
k2 = (pi/tp)/sin(pi*te/tp);
k3 = (pi/tp)/tan(pi*te/tp);
k4 = t0 - te;
syms x;
y = (1/(x^2+k1))*(k2*exp(-te*x) + x - k3) - k4/(exp(E*k4)-1) + 1/E;
alpha = numeric(solve(y))

_______________________________________________

Results:

CASE 1:
Parameters: t0 = 1; tp = 0.41; te = 0.55; ta = 0.04; tc = 0.58;
Results: E = -18.3400 , alpha = -1.3604
CASE 2:
Parameters: t0 = 1; tp = 0.48; te = 0.59; ta = 0.027; tc = 0.72;
Results: E = 36.7243 , alpha = 5.7369
CASE 3:
Parameters: t0 = 1; tp = 0.46; te = 0.66; ta = 0.027; tc = 0.77;
Results: E = 36.3583 , alpha = 1.9533
CASE 4:
Parameters: t0 = 1; tp = 0.50; te = 0.80; ta = 0.08; tc = 1;
Results: E = 11.1581 , alpha = 0.3510


Best regards :D
 

matlab equation

thank friend, but i don't have the function numeric under matlab 7, can you send me the m file of this fuction
thanks

Added after 15 minutes:

thank you friend I have replaced the function numeric by eval and it work, tahnk you very mutch

Added after 10 minutes:

I have one last question friend,
the equation (*) in the document (the result of the integration ) can I do symbolic integration with matlab (using int function) to assure my integrated result and about the 0 , I have replaced it integration by 0, is it true ??? (normaly it is an unkwon arbitery constant) if it is not the case what should I do.

Thank you
 

solve for variable matlab

Dear friend

You've made a mistake in equation (**), on the right hand t0 must be tc. The correct equation is:


See this M-file for Case1:
___________________________________________
clc; clear; close all;
%Parameters of Case 1:
t0 = 1;
tp = 0.41;
te = 0.55;
ta = 0.04;
tc = 0.58;
% ******************************************
% Finding e: { e*ta = 1 - exp(-e*(tc-te)) }
syms e;
f = e*ta - 1 + exp(-e*(tc-te));
R_e = eval(solve(f));
E = R_e(1) + R_e(2) % E = nonzero root of f (one root is zero)
% ******************************************
% Finding alpha = x:
k1 = (pi/tp)^2;
k2 = (pi/tp)/sin(pi*te/tp);
k3 = (pi/tp)/tan(pi*te/tp);
k4 = tc - te;
syms x;
y = (1/(x^2+k1))*(k2*exp(-te*x) + x - k3) - k4/(exp(E*k4)-1) + 1/E;
alpha = eval(solve(y))
% ******************************************
% is {int(g(t))} equal zero ?
Ee = 1; % an arbitrary value for Ee
syms t;
E0 = -Ee/(exp(alpha*te)*sin(pi*te/tp));
g1 = E0*exp(alpha*t)*sin(pi*t/tp); % for interval: [0 te]
Ig1 = eval(int(g1,0,te))
g2 = -(Ee/(E*ta))*(exp(-E*(t-te))-exp(-E*(tc-te))); % for interval: [te tc]
Ig2 = eval(int(g2,te,tc))
IG = Ig1+Ig2

___________________________________________
Results:
E = -18.3400
alpha = 3.9462
Ig1 = 0.0164
Ig2 = -0.0164
IG = 7.6328e-017


The value of IG is less than eps (In MATLAB eps=2.2204e-016 (Floating-point relative accuracy)), so IG={int(g(t)} is zero.

Best :D
 

    Foufou

    Points: 2
    Helpful Answer Positive Rating
how to resolve sin(0)/0 in matlab?

thanks friend,

Added after 32 minutes:

Dear friend can i receive your Email adress,
thanks
 

root of an equation matlab

you don't need to set value for t0 tp ...
use:
syms params
witch params is t0 tp and so on.
then write your function(not equation I mean all in one hand) like this:
f=e*Ta-1+exp(-e*(t0-te) );
and finally use solve:
solve(f)
here is the code:

syms e Ta t0 te
f=e*Ta-1+exp(-e*(t0-te) );
solve(f)
 

root equation in matlab

Hi AhSa2003

I think Saeidj is true. In Matlab, "solve(eq,var)" solves the equation eq=0 for the variable var. In Fofou equation: eTa=1-exp(-e(t0-te)) the unknown variable is e, so:
eq = e*ta -1 + exp(-e*(t0-te))
var = e

If you do not set the variabels t0, ta, and te with known values , Matlab only return one root (e=0), while it may have two roots.

syms e ta t0 te;
f=e*ta-1+exp(-e*(t0-te) );
x = solve(f,e)

Matlab returns: x = 0

But if you set the known values:

t0 = 1;
te = 0.55;
ta = 0.04;
syms e;
f=e*ta-1+exp(-e*(t0-te) );
x = eval(solve(f,e))

Matlab returns: x = 24.9997 , 0
 

known variables and solve equation matlab

use perl
 

how to solve equation in matlab for a variable

yes i don't test it in matlab
Yes u are right
 

eval equation matlab

Dear saeidj,
When I compute the g(t) function using the e and alpha value calculated above the trapz function for calculating numeric integrationd doesn't give 0, can you help me to resolve this problem.
Thanks
 

finding roots of an equation using matlab

Dear Foufou

Trapz(t,g) computes an approximation of the integral of g(t) with respect to t using trapezoidal integration. For example in CASE1 you should:

1- Integrate on [0 0.55] (Ig1 = trapz(t,g1) and t=0:Ts:0.55).
2- Integrate on [0.55 0.58] (Ig2 = trapz(t,g2) and t=0.55:Ts:0.58).
So, IG = Ig1 + Ig2.

The integration intervals are small, so to accurate the integration you should use very small Ts.

If Ts=1e-7 then:

E = -18.34002472196918
alpha = 3.94620051353478
Ig1 = 0.01636861161367
Ig2 = -0.01636861161366
IG = 1.655273140777069e-014 (notice that this is only an approximation).


If you use smaller Ts, IG --> 0. (If Maximum variable size allows it).

The M-file (for CASE1) is:
clc; clear; close all;
%-------------------------------------------------------------------------
%Parameters of Case 1:
t0 = 1;
tp = 0.41;
te = 0.55;
ta = 0.04;
tc = 0.58;
format long;
%-------------------------------------------------------------------------
% Finding e: { e*ta = 1 - exp(-e*(tc-te)) }
syms e;
f = e*ta - 1 + exp(-e*(tc-te));
R_e = eval(solve(f));
E = R_e(1) + R_e(2) % E = nonzero root of f (one root is zero)
%-------------------------------------------------------------------------
% Finding alpha = x:
k1 = (pi/tp)^2;
k2 = (pi/tp)/sin(pi*te/tp);
k3 = (pi/tp)/tan(pi*te/tp);
k4 = tc - te;
syms x;
y = (1/(x^2+k1))*(k2*exp(-te*x) + x - k3) - k4/(exp(E*k4)-1) + 1/E;
alpha = eval(solve(y))
%-------------------------------------------------------------------------
% is {int(g(t))} equal zero ? (Using TRAPZ function)
Ee = 1; % an arbitrary value
E0 = -Ee/(exp(alpha*te)*sin(pi*te/tp));
%................
t = 0:1e-7:te;
g1 = E0*exp(alpha*t).*sin(pi*t/tp); % for interval: [0 te]
Ig1 = trapz(t,g1)
%................
t = te:1e-7:tc;
g2 = -(Ee/(E*ta))*(exp(-E*(t-te))-exp(-E*(tc-te))); % for interval: [te tc]
Ig2 = trapz(t,g2)
%................
IG = Ig1+Ig2


Best, (My Email: wri2t A.T Y.A.H.O.O) :D
 

    Foufou

    Points: 2
    Helpful Answer Positive Rating
matlab resoudre equation solve

thanks friend,
I will sent you a message to your Email adress
Best regard
foufou

Added after 15 minutes:

thanks friend,
I will send you a message to your Email adress
Best regard
foufou
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top