# Dassl Mex file compilation to Matlab 5.3 and 6.5!

### Giovani Tonel (view profile)

16 Oct 2007 (Updated )

I have compiled a Dassl solver version (MATLAB MEX INTERFACE), in order to use with Matlab (version

dydt(t, y, yp, rpar)
```function [dev,ires] = dydt(t, y, yp, rpar)
%
% dydt function
%___________________________________________________________________________
%___________________________________________________________________________
%
% Edited by: Giovani Tonel, Taking Master Degree in Chemical Engineering
% Chemical Engineering Department - GIMSCOP/ALSOC
% Federal University of Rio Grande do Sul - UFRGS
% Porto Alegre, RS - Brazil
% Phone: +55 51 3308 4166 (GIMSCOP - Room 2)
% Website: http://www.enq.ufrgs.br/gimscop
% October 2007; Last revision: 15-October-2007
%___________________________________________________________________________
%___________________________________________________________________________

global DEBUG;

% only for test
a1      =   rpar(1) ;
b2      =   rpar(2) ;
%********************

plot_do = 0;

if plot_do
%########################################################################
%
% solving a DAE problem
%
dev(1)  =   yp(1) + 4*y(1)+ 0*a1         ;
dev(2)  =   yp(2) + 6*y(2)+ 0*b2         ;
dev(3)  =   y(3) - y(1)-2.0              ;
%
%########################################################################
%
%
else
%########################################################################
%
% solving a ODE problem(dxdt)
%
dev(1)  =   yp(1) + 4*y(1)        ;
dev(2)  =   yp(2) + 6*y(2)        ;
dev(3)  =   yp(3) - y(1)-2.0      ;
%
%########################################################################
end

ires    = 0;

%         IRES is an integer flag which is always equal to
%         zero on input. Subroutine RES should alter IRES
%         only if it encounters an illegal value of Y or
%         a stop condition. Set IRES = -1 if an input value
%         is illegal, and DDASSL will try to solve the problem
%         without getting IRES = -1. If IRES = -2, DDASSL
%         will return control to the calling program
%         with IDID = -11.

if ( DEBUG > 9 )
buf1 = sprintf('%.4e ',y);
buf2 = sprintf('%.4e ',yp);
buf3 = sprintf('%.4e ',dev);
disp(sprintf('(Debug) dydt.m: t=%.2e y=%s yp=%s dev=%s', t,buf1,buf2,buf3));
if ( DEBUG > 99 )