help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Creating .oct files


From: Peter Gawthrop
Subject: Creating .oct files
Date: Wed, 19 Apr 2000 08:52:01 +0100 (BST)

Hi,

I am developing a set of system modelling tools which
ultimately generate .m files. (more info is at
http://www.mech.gla.ac.uk/~peterg/software/MTT/).

To speed things up, I now generate .oct files based on the
"Dynamically Linked Functions" section of the octave manual. As I know
nothing about c++ I used the "oregonator.cc" example as a
template. This all works fine.

At the moment (for example) I generate:
   rcPPP_cseo.oct
   rcPPP_cse.oct
   rcPPP_smxa.oct
   rcPPP_smxax.oct

and call them from the .m file given here.


function [y,x] = rcPPP_sim(x0,u,t,par);
% [y,x] = rcPPP_sim(x0,u,t,par);
%System rcPPP, representation sim, language m;
%File rcPPP_sim.m;
%Generated by MTT on Tue Apr 18 18:30:34 BST 2000;
%

  ## Initialise
  ui  = zero_input(2);  # Zero the input
  xi = x0;              # Read in initial state


  yi = rcPPP_cseo(xi,ui,t(1),par);    # First output

  ##Sizes
  N = length(t);

  ## Initialise  arrays   
  x = zeros(1,N);
  y = zeros(1,N);
  y(:,1) = yi(:);
  A = zeros(1,1);
  Ax = zeros(1,1);
  dx = zeros(1,1);

  ## Step size
  dt = t(2)-t(1);

  for i = 1:N
    ti = t(i);
    ui = u(:,i);
    y(:,i) = yi;
    x(:,i) = xi;
    dxi = rcPPP_cse(xi,ui,ti,par); # State derivative
    A = rcPPP_smxa(xi,ui,dt,par);       # (I-Adt)
    A = reshape(A,1,1);
    Ax = rcPPP_smxax(xi,ui,dt,par);     # (I-Adt)x
    xi = A\(Ax + dxi*dt);        # Implicit update
    yi = rcPPP_cseo(xi,ui,ti,par);    # Output 
  endfor;                       

endfunction

To make things even faster, I would like to turn this rcPPP_sim.m file
into a .oct file. This is more complicated than the  "oregonator.cc"
example as:

1. It calls user defined .oct functions
2. It calsl the octave function  reshape
3. It uses the octave "\" operator.

I would be really gratefull if an octave expert could convert this
function into a .cc file for me to show me how to do it.

         Thanks,

         Peter.

PS If anyone has an interest in the MTT modeling tools, please let me
know. I hope to distibute freely at some point in time. 

-- 
=============================================================
Peter J. Gawthrop, 
Centre for Systems & Control
          and
Department of Mechanical Engineering

Room number: James Watt 603 
                (Third floor opposite the seminar room)
WWW: 
  http://www.mech.gla.ac.uk/~peterg  (Personal)
  http://www.mech.gla.ac.uk/Control/ (CSC)
  http://www.mech.gla.ac.uk/         (Department)

E-mail: 
  address@hidden

Address:
  Department of Mechanical Engineering,
  University of Glasgow,
  GLASGOW. G12 8QQ
  Scotland.

Tel: 
   +44 141 330 4960 (Direct)
   +44 141 330 4349 (Secretary)

   +44 141 339 8855 (University switchboard)

Fax: 
  +44 141 330 4343
=============================================================



-----------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.che.wisc.edu/octave/octave.html
How to fund new projects:  http://www.che.wisc.edu/octave/funding.html
Subscription information:  http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]