Path: news.mathworks.com!not-for-mail
From: "sdfs sfdf" <ofeus18@yahoo.de>
Newsgroups: comp.soft-sys.matlab
Subject: s-function, parameter
Date: Tue, 27 Oct 2009 11:24:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 64
Message-ID: <hc6l8j$4k0$1@fred.mathworks.com>
Reply-To: "sdfs sfdf" <ofeus18@yahoo.de>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1256642643 4736 172.30.248.37 (27 Oct 2009 11:24:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 27 Oct 2009 11:24:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1930141
Xref: news.mathworks.com comp.soft-sys.matlab:580317


Hello,

i have an s-function to which the parameter "L" is handed over. The beginning of the s-function looks like this :
Code:
function [sys,x0,str,ts] = Kinetik_aerob(t,x,u,flag,V_l,c_X_0,A,L)
 
switch flag,
   
  case 0,
     [sys,x0,str,ts]=mdlInitializeSizes(V_l,c_X_0,A,L);
     
  case 3,
     sys=mdlOutputs(t,x,u,V_l,c_X_0,A,L);  
   
  case {1, 2, 4, 9},% unexpected flags
     
  otherwise
    error(['Unhandled flag = ',num2str(flag)]);
 
end
%
function [sys,x0,str,ts]=mdlInitializeSizes(V_l,c_X_0,A,L)
 
sizes = simsizes;
 
sizes.NumContStates  = 0;   
sizes.NumDiscStates  = 0;  
sizes.NumOutputs     = 7; 
sizes.NumInputs      = 6; 
sizes.DirFeedthrough = 1; 
sizes.NumSampleTimes = 1;   
 
sys = simsizes(sizes);
%
x0  = [];
str = [];
ts  = [0 0];
%


function sys=mdlOutputs(t,x,u,V_l,c_X_0,A,L)
 
%Einlesen
c_X       = u(1);     %[g/l] Biomassekonzentration
PFD       = u(2);     %[?E/m?s] PFD(PAR)
E         = u(3);     %[MJ]
Ab        = u(4);     %[g/l]
Temp      = u(5);     %[?K]
Gh        = u(6);     %[W/m^2]



%Now the part with which i have problems. The if-else-construction:
if L==1
PFD     = PFD*(  (-0.9184 * c_X) / (0.1447 + c_X) + 1.002 );

elseif L==3
PFD     = PFD*	( (-0.9714 * c_X) / (0.04037 + c_X) + 1 );   


It seems as if the s-function cannot handle this if-construction or the if-construction doesn't recognize the parameter "L". If i calculate "PFD" without the if-construction it works. What is wrong? Please help me ;-)

Thank you
bye