Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: using global variable in equation used by ODE solver
Date: Tue, 3 Nov 2009 18:35:04 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 25
Message-ID: <hcpt4o$n8b$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257273304 23819 172.30.248.38 (3 Nov 2009 18:35:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 3 Nov 2009 18:35:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2031300
Xref: news.mathworks.com comp.soft-sys.matlab:582125


i have problem in my program
i created one variable 'v' in main file , the value of that variable is used in the equation in other program as global variable.

when i run main program having ode45 solver for that equation having variable 'v' it gives error 
??? Error using ==> odearguments at 117
Solving EGG2 requires an initial condition vector of length 1.
can any body guide me about this.

is there is way to use value of one variable in other function (equation) which will be solved through ODE solver.
my code is 

main program
--------------------
clc;
clear all;
global v;
x=[-1;1];  
v= 2*x;
[x,y]= ode45(@eg,[-1 1],[0.1],v);
plot (x,y);
--------------
function  dy =eg(x,y)
global v; 
dy= -v*y + x;
end