<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#330000">
    <div class="moz-cite-prefix">On 26/11/2012 20:33, Rodrigo Thomas
      wrote:<br>
    </div>
    <blockquote
cite="mid:CA+FEx82Ed_GAAUJ21QRcLK6cjQ8eSc9sqmx1b5HU28SvZ_-c1g@mail.gmail.com"
      type="cite">Hello,
      <div><br>
      </div>
      <div>I'm having a problem to solve complex ordinary differential
        equations like (a simplified one):</div>
      <div><br>
      </div>
      <div>dx/dt = i*x.</div>
      <div><br>
      </div>
      <div>I tried to use: </div>
      <div><br>
      </div>
      <div>
        <div>-->function xdot=f(x,t)</div>
        <div>-->xdot=%i*x</div>
        <div>-->endfunction</div>
        <div>-->x0=[1;0];</div>
        <div>-->t0=0;</div>
        <div>-->t=linspace(0,10,100);</div>
        <div>-->y=ode(x0,t0,t,f);</div>
      </div>
      <div>-->plot(t,y)</div>
      <div><br>
      </div>
      <div>but Scilab give the plot of a constant line in x=1 and a
        exponential term (real expoent). How can I solve it?</div>
      <div><br>
      </div>
      <div>hug,</div>
      <div>Thomas.</div>
      <div><br>
      </div>
      <br>
    </blockquote>
    <br>
    Hi Thomas,<br>
    <br>
    Indeed, the result of this ODE is very different than the result of
    the naive one:<br>
    <br>
    xx(:,1) = x0;<br>
    dt=0.1;<br>
    tt = 0:dt:10;<br>
    for i=1:size(t,"*")<br>
    xx(:,i+1) = xx(:,i)+dt*f(xx(:,i));<br>
    end<br>
    <br>
    <br>
    Now, the ODE help page seems to imply that ODE should be used with
    rela matrixes and functions<br>
    <br>
    So, the solution seems to be to write real functions, something like<br>
    <br>
    function xdot =f(x)<br>
        im = x(1)<br>
        re = x(2)<br>
    <br>
        dim = re<br>
        dre = -im<br>
    <br>
        xdot = [dre; dim]<br>
    endfunction<br>
    <br>
    hop this helps<br>
  </body>
</html>