Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9126581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:04:27+00:00 2026-06-17T07:04:27+00:00

I wrote a code for solving a ode (cell growth over time until a

  • 0

I wrote a code for solving a ode (cell growth over time until a certain product concentration). since my model changes when the value for y(3) is bigger than a constant (Pmx) i implemented the odeset event function.
IF the event happens depends on the values given in the function.

FOR debugging i would like to set a if statement to stop the function and only use the first ode23 function results to plot (not yet implemented) (see code)

i think its also a problem with end standings isnt it?
thx in advance

function [T,Y,TE,YE,IE, Y1, T1] = SimplePerfusionMode(tf,F)

%% DESCRIPTION
% INPUT:
%   tf: final time [h]
%    F: Feed stream [Lh^-1]
% OUTPUT
%   T:  processing time [h]
%   Y:  states functions (X, S, P)
%   TE: time at which event occurs [h]
%   YE: Solution values corresponding to TE (g/l)
%   IE: Indices into the vector returned by the events function. The values
%   indicate which event the solver detected.
%
% SAMPLE CALL: 
  % [T,Y,TE,YE,IE, Y1, T1] = SimplePerfusionMode(30,15)
% 

%




% Initial values
X0 = 0.06; %kgm-3 
S0 = 110; %kgm-3
P0=0 ;

%%%%%%%%%%%%
%% Solve ODEs until the terminal event P=Pmx
%%%%%%%%%%%%


tspan = [0 tf]; y0 = [X0 S0 P0];



options = odeset('Events',@(t,y) MyEvent(t,y,F,V,Rp,Pmx));
[T,Y,TE,YE,IE] = ode23(@(t,y) process(t,y,mumax,Ksx,Kix,Pix,Pmx,Kis,Pis,Pms,qsmax,Kss,alp,qpmax,Ksp,Kip,Pip,Pmp,F,S,Rx,Rs,Rp,V),tspan,y0,options);


%%%%%%%%%%%%%
% Solving ODE for dx/dt=0
%%%%%%%%%%%%% IMportanT HERE

tspan1=[TE tf]
  y01=[Y(end,1) Y(end,2) Y(end,3)]

if (TE==tf)
    disp('use lower stream feed to guarantee massive growth');
    return
else
  [T1,Y1] = ode23(@(t,y) process2(t,y,mumax,Ksx,Kix,Pix,Pmx,Kis,Pis,Pms,qsmax,Kss,alp,qpmax,Ksp,Kip,Pip,Pmp,F,S,V,Rx,Rp,Rs),tspan1,y01);
end


% --------------------------------------------------------------
% Plotting AREA
not displayed

%% Process Model equations - see 
% --------------------------------------------------------------
function dydt = process(t,y,mumax,Ksx,Kix,Pix,Pmx,Kis,Pis,Pms,qsmax,Kss,alp,qpmax,Ksp,Kip,Pip,Pmp,F,S,Rx,Rp,Rs,V)
    mu = (mumax*y(2)) / (Ksx+y(2));
dydt = [-F/V*(1-Rx)*y(1)+y(1)*mu*(1-(y(3)-Pix)/(Pmx-Pix))*(Kix/(Kix+y(2))); %X
F/V*(S-(1-Rs)*y(2))-(qsmax*(y(2)/(Kss+y(2)))*(1-((y(3)-Pis)/(Pms-Pis)))*(Kis/(Kis+y(2))))*y(1);
     -F/V*(1-Rp)*y(3)+F/V*(1-Rx)*y(1)+y(1)*mu*(1-(y(3)-Pix)/(Pmx-Pix))*(Kix/(Kix+y(2)))*alp+qpmax*(y(2)/(Ksp+y(2)))*(1-(y(3)-Pip)/(Pmp-Pip))*y(1)*(Kip/(Kip+y(2)));
     ];  
end   
% --------------------------------------------------------------
function [value,isterminal,direction] = MyEvent(t,y,F,V,Rp,Pmx)

value = y(3)-Pmx;     % Detect height = 0 STOP the Product inhibitory effect
  isterminal = 1;   % Stop(!!!!) the integration
direction =  1;   % Positive direction only
end
% --------------------------------------------------------------


function dydt = process2(t,y,mumax,Ksx,Kix,Pix,Pmx,Kis,Pis,Pms,qsmax,Kss,alp,qpmax,Ksp,Kip,Pip,Pmp,F,S,V,Rx,Rp,Rs)
    mu = (mumax*y(2)) / (Ksx+y(2));
dydt = [ 0; %X
      F/V*(S-(1-Rs)*y(2))-(qsmax*(y(2)/(Kss+y(2)))*(1-((y(3)-Pis)/(Pms-Pis)))*(Kis/(Kis+y(2))))*y(1);
     -F/V*(1-Rp)*y(3)+qpmax*(y(2)/(Ksp+y(2)))*(1-(y(3)-Pip)/(Pmp-Pip))*y(1)*(Kip/(Kip+y(2)));
    ]; 
    end
% --------------------------------------------------------------

end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:04:28+00:00Added an answer on June 17, 2026 at 7:04 am

    I am not sure which of these exactly you are interested in, but here are some possible solutions:

    If your goal is …

    • to stop the program while debugging without editing the code: Use a breakpoint
    • to stop the progam by editing the code: Use the keyboard command
    • to run a different part of the code depending on whether you run it yourself, or whether it is used somewhere else: Use the isdeployed command
    • to run a different piece code depending on whether you are debugging or running it: Feed the program a boolean input variable, say nowDebugging and use if statements that depend on it.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote the following code for solving a problem but it doesn't work. The
I was revisting some code I wrote a long time ago, and decided to
I was solving a Python question on CodingBat.com. I wrote following code for a
I wrote following code I am solving a puzzle I when compiled this part
I wrote code to get name of printer which is installed in my system.but
I wrote code first without using functions to prototype, and of course, it worked
I recently wrote code that didnt work as i would expect, it was: message
i added sharekitkit my project. And wrote code like here : SHKItem *item =
I wrote some code in VHDL that is expected to look at a rotory
I wrote this code for zoom in/out . it works but even with one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.