# Deterministic model of lambda-phage lysis/lysogeny [MATLAB] [closed]

Project 1 Base:

Can someone please help me understand what I need from Project 1 Base code to do questions 1 and 2 from the first image? I'm new to MATLAB so a thorough explanation would be great.

-

## closed as off-topic by WYSIWYG♦, Bez, Chris♦, Cornelius, Rory MJul 31 '14 at 11:46

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Homework questions are off-topic on Biology unless you have shown your attempt at an answer. For more information see our homework policy." – WYSIWYG, Bez, Chris, Cornelius, Rory M
If this question can be reworded to fit the rules in the help center, please edit the question.

This can be done using loop method or Forward Eular's. I don't know which one is easier for this question nor would I know how to do it myself since I have never taken a programming course before and am somehow expected to know how to do all this. – Parth Ghetia Apr 12 '13 at 0:02

For homework questions, the policy is to see some work from the poster. Since you don't know programming, I've outlined what the code is doing, beyond the simple operations (+, -, /, *, ^), to get you started. I think you should be able to implement the models with this information, and I'd be happy to confirm your own answers.

So the best way to figure out what any line of code means, in any language, is to type it and see what happens. To help you get started with programming in MATLAB:

Any text following a % (on the same line) is a comment: it does nothing in the program, and is only there for you to write notes to yourself.

The first two sections, Time-Related Constants and Simulation Constants, are just setting variables. It's like saying x = 3, so that later on you can do other operations with x.

The semicolon at the end of a line (in MATLAB) suppresses the output of the line. See what happens if you type x = 3; versus x = 3 at the command prompt.

In iteration constants, length is just a function that tells you the length of the vector. X_rna_0 was previously initialized to go from 0 to 1.4 in steps of 0.2: the syntax is vector_name = start:step:end.

The simulation variables section is creating xyz-matrices, with all values initialized to zero. The length in x is xr_max, and so on. The idea is that, later on, at each step in Euler's method and each value of xr_max and xp_max, you'll save the value of X_rna.

The initial conditions are being set using meshgrid, which is best explained here. The : means all of the rows/columns, corresponding to position: say you had a 3 x 3 matrix called apple. apple[:,1] gives you all the first column (1) of all three rows. apple[1,:] gives you the first row (1) of all three columns. The .' means that the matrix is being transposed: again, the best way to see what's going on is to create a matrix of your own, perform the operation, and see if what you get is what you thought it would be.

For loops, you can read about here, for a start. I do not think understanding this loop requires more information than that page.

Dot before ^2 means that each element of the matrix is being squared; you are not multiplying the matrix by itself.

That should decipher most of the code for you. If you have further questions, feel free to comment here.

EDIT: Question 2 asks you to make a plot. A plot of y vs. x would be made by typing plot(x,y)

Also, help on a particular MATLAB function can be accessed by typing help name_of_function.

-

This is a set of ordinary differential equations. Proceed like this

1. Make a matlab function for the ODEs that define the system (equations 1,2,3,4). The function should return a 4 dimensional vector which is basically the dy/dt (the rate equation)
2. in the main program declare the initial values of different components. There is no absolute rule for what it should be and it is based on your prior knowledge of the system
3. in the main program write a module to integrate the rate function over a time interval. there are several numerical algorithms to do it such as Euler, implicit euler, runge-kutta, polynomial interpolation- predictor corrector methods (Adam Bashworth) etc. If you want to improve your knowledge on the numerical methods then write your own code for any algorithm. A good book on basics of numerical methods can be referred. Otherwise, you can use inbuilt ODE solvers in Matlab.

A note on numerical methods for solving ODEs: what you precisely do is add-up and update the rate function in small intervals of time. The very basic method is euler in which you just implement this:

y = y + h*f(x,t)....... explicit/forward euler
y = y + h*f(x,t+h)...... implicit/backward euler


where dy/dx =f(x,t) and h is a small time interval

So what you have to do, exactly, is to run a loop which goes from t=t_initial to t=t_final with small increments of h. You can use any basic loop such as for loop or while loop. for loops are quite easy to implement. (the basic syntax is - for(initial;final condition; increment function) which in Matlab is as easy as for t=t_initial:h:t_final

Within the loop you apply the integration operation.

More advanced techniques use variable step size to improve the performance. You can use the inbuilt ODE solvers if you require better performance and accuracy.

As for your homework.. You already have the code; just need to put the parameters.

-