I need help with my program

2 views (last 30 days)
Wayne
Wayne on 4 May 2012
Good day,
I have been debugging my program for the past few hours and now I am stuck. My program's aim is to solve an ODE. I hardcoded values at first and it worked, but the problem was 'generalizing' it.
Here's my program:
function [T,M] = rep_plot(tMax)
%
% OUTPUT VARIABLES
% T - ode solver time vector
% M - array containing protein and mRNA concentrations
% * column 1 - mRNA 1
% * column 2 - mRNA 2
% * column 3 - mRNA 3
% * column 4 - protein 1
% * column 5 - protein 2
% * column 6 - protein 3
%
% INPUT VARIABLES
% tMax - duration of the simulation
% initializes the model parameter struct
p = setupPara();
m = [p.m.mRNA1;p.m.mRNA2;p.m.mRNA3;p.m.prot1;p.m.prot2;p.m.prot3];
% runs the ode solver
[T,M] = ode45(@repress,[0 tMax],m,p);
% plot & set the graphing variables of the ODE (concerned only with
% protein)
plot(T, M(4,:), T, M(5,:), T, M(6,:));
title('Elowitz and Leibler Repressilator model')
xlabel('time (seconds)');
ylabel('Protein concentration (# molecules)');
legend('molecule I', 'molecule II', 'molecule III');
function dM = repress(T, M, p)
% INPUT VARIABLES
% T - time vector
% M - mRNA concentration(1st 3 variables), protein concentration
% (last 3 variables)
% p - model parameter struct (check setupPara)
%
% ABBREVIATIONS (would be used to simplify the discussion of certain parts
% of the program)
% mtrans - maximum transcription rate(transcripts/second) [set to 0.5]
% nrepm - number of repressor molecules needed to half-maximally repress
% the transcription rate of the gene (molecules/cell) [set to 40]
% Hcoeff - Hill coefficient [set to 2]
% lmRNA - average lifetime of mRNA (seconds) [set to 120]
% lprot - average lifetime of the protein (seconds) [set to 600]
% treff - translational efficiency (proteins/mRNA transcript) [set to 20]
% memory allocation
dM = zeros(length(M),1);
% store the state variables
mRNA1 = M(1);
mRNA2 = M(2);
mRNA3 = M(3);
prot1 = M(4);
prot2 = M(5);
prot3 = M(6);
% store the max transcription rate in transcripts per second
k_trans1 = ...
k_trans2 = ...
k_trans3 = ...
% Set the mRNA and protein degradation rates (per second)
...
% proteins per transcript per sec
...
% set the Hill coefficients of the repressors
n1 = p.y.Hcoeff;
n2 = p.y.Hcoeff;
n3 = p.y.Hcoeff;
% the differential equations governing the state variables:
% mRNA concentration = mRNA concentration + transcription given
% repressor concentration
dM(1) =...
dM(2) =...
dM(3) =...
% protein concentration = translation - protein degradation
dM(4) = ...
dM(5) = ...
dM(6) = ...
function p = setupPara(~)
% memory allocation
m = struct('mRNA1', [], 'mRNA2', [], 'mRNA3', [], 'prot1', [], 'prot2',...
[], 'prot3', []);
y = struct('nrepm',[],'Hcoeff',[],'lmRNA',[],'lprot',[],'treff',[]);
mtrans = struct('p1',[],'p2',[],'p3',[]);
% 3 protein and 3 mRNA concentrations
m.mRNA1 = 6;
m.mRNA2 = 7;
m.mRNA3 = 8;
m.prot1 = 9;
m.prot2 = 10;
m.prot3 = 11;
% values that remain fixed no matter how many simulations are done
y.nrepm = 40;
y.Hcoeff = 2;
y.lmRNA = 120;
y.lprot = 600;
y.treff = 20;
% changing values for certain parts of the assignment
mtrans.p1 = 0.5;
mtrans.p2 = 0.5;
mtrans.p3 = 0.5;
% stores the individual parameter structs into the main parameter struct
p = struct('m', m, 'y', y, 'mtrans', mtrans);
This is the recurring error message:
Error using rep_plot>repress (line 62)
Not enough input arguments.
Error in odearguments (line 88)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 114)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in rep_plot (line 22)
[T,M] = ode45(@repress,[0 tMax],m,p);
Please help me pinpoint where I did wrong, and how you would change it. Any help would really be appreciated.
Thanks,
Wayne
  1 Comment
Jan
Jan on 4 May 2012
Please, Wayne, format your code as explained in the "Markup help" link.
Currently the code is not readable and it is hard to find the "line 62". But the error message seems to be clear: You have not defined enough input arguments.

Sign in to comment.

Answers (1)

Jan
Jan on 4 May 2012
Sumbitting the parameters as a struct is not supported as far as I know. It is recommended to use anonymous functions to add parameters, see: Answers: benefit-of-using-anonymous-functions-for-ODE

Categories

Find more on Programming in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!