Get the time constant from a nonlinear system of ode
    3 views (last 30 days)
  
       Show older comments
    
Hi, i'm simulating using simulink a nonlinear system, of which i know the set of nonlinear ODEs, and i need to calculate its time constant (and i'm DESPERATE)
I already solved 2 other problems like this. In the first one the system was linear, so i took it to state-space form and i found the time constant using the damp function. The second one (made by only one ODE) was nonlinear because i had 2 of the input variables multiplicating the time dependent variable, so i managed to solve it using dsolve and keeping the solution in a symbolic form, using the following code
%u(1) = qf;
%u(2) = qc;
%syms Te(t) M Tf Tc
%Te(t) = dsolve(diff(Te,t) == -(u(1)+u(2)) / M * Te + Tf/M*u(1) + Tc/M*u(2), Te(0) == 0)
%u(1) and u(2) are the values of the input variables, which are known.
and i found the solution
Te(t) =Tc/2 + Tf/2 - (exp(-t/(5*M))*(Tc + Tf))/2
In which the time constant should be 5*M (am I wrong?). Since M is usually a known value i use Tao=5*M to calculate the time constant.
In the last problem i have a more complex system of non linear ODEs, but i need to find a way to calculate the time constant in that too.
syms i_(t) ve_(t) y_(t) R_ L_ M_ k_
eqn1 = diff(y_)  == ve_
eqn2 = diff(i_) == u/L_ - (R_/L_)*i_
eqn3 = diff(ve_) == -(k_/M_)*(i_*i_)/y_ + g 
[y_Sol(t), i_Sol(t), ve_Sol(t)] = dsolve(eqn1,eqn2,eqn3,y_(0) == y0,i_(0) == i0 ,ve_(0) == ve0)
i_ ve_ and y_ are the state variables, u is a known value, the other ones are parameters which i keep as symbles to try to obtain a solution like the previous one.
The problem is that applying dsolve to this system i get the following error:
Error using sym/subsindex (line 685)
Invalid indexing or function definition. When defining a function,
ensure that the body of the function is a SYM object. When indexing,
the input must be numeric, logical or ':'.
Where the problematic line is the one of eqn3
How can i find the time constant of this problem?
Thank you VERY VERY much for your help, and sorry if my english isn't perfect.
0 Comments
Accepted Answer
  Star Strider
      
      
 on 6 Oct 2016
        The problem you saw was thrown by the subscripts (or function assignments) in the dsolve output assignments. Correcting that, and some other additions to your syms call, removes the syntax error:
syms i_(t) ve_(t) y_(t) R_ L_ M_ k_ u g y0 i0 ve0
eqn1 = diff(y_)  == ve_;
eqn2 = diff(i_) == u/L_ - (R_/L_)*i_;
eqn3 = diff(ve_) == -(k_/M_)*(i_*i_)/y_ + g;
[y_Sol, i_Sol, ve_Sol] = dsolve(eqn1,eqn2,eqn3,y_(0) == y0,i_(0) == i0 ,ve_(0) == ve0)
This unmasks the problem that dsolve cannot find a solution to your system. I leave that to you to sort out.
4 Comments
  Star Strider
      
      
 on 7 Oct 2016
				Marco Mutti’s ‘Answer’ moved here —
Well, of course i'm not asking you to fix my system :) The important thing is that the code is ok, now i will concentrate to find out what's wrong.
Thank you again
  Star Strider
      
      
 on 7 Oct 2016
				My pleasure.
I want to help you fix your code, but I need to know what you intend to code in order to help you find the problem. I see nothing wrong with the code you posted, so knowing the system you intended to code would help me figure out what is not working correctly. Scanning it and attaching it as a .png image or .pdf file would work.
More Answers (0)
See Also
Categories
				Find more on Time and Frequency Domain Analysis in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
