Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.

Topic: Not sure of my misuse of varargin
Replies: 1   Last Post: Sep 18, 2013 5:58 PM

 Messages: [ Previous | Next ]
 Dejan Cvijanovic Posts: 1 Registered: 9/18/13
Not sure of my misuse of varargin
Posted: Sep 18, 2013 5:34 PM

Hi all,

My code:

function sens_analysis

global par;
global re;
global par_n;
global P;
time=linspace(0,800,4000);
P=zeros(length(time),9)

pdemeshpop_final_re_sens;
re_0 = re;
par = re;
s_nom_ss = P(length(time),7);
delta = 0.05;
par_n = par*(1+delta);
pdemeshpop_final_re_sens_par(par_n);
s_pert_ss = P(length(time),7);
abs_sens = (s_pert_ss - s_nom_ss)/(delta*re_0);
rel_sens = abs_sens*(re_value/s_nom_ss);
end

I am trying to write a function that calls another function, stores the last value, change a parameter and runs a very similar function. When I do this however, I get the error :

"Reference to a cleared variable varargin.

Error in pdemeshpop_final_re_sens_par (line 76)
re = varargin(1); %Reduction in efficiency of virus production in P1mod

Error in sens_analysis_re (line 20)
pdemeshpop_final_re_sens_par(par_n);"

I am not sure where I am messing up. For concreteness, I made the global variables in all three functions the same.

The other two functions start like this:

"function pdemeshpop(varargin)

global par;
global re;
global P;
global par_n;
.
.
.
.
"

"function pdemeshpop(varargin)

global par;
global re;
global P;
global par_n;
.
.
.
"

Can someone please explain clearly where I might be going wrong?

Date Subject Author
9/18/13 Dejan Cvijanovic
9/18/13 dpb