|
Hi,
I try your programm and didn't get your error message. Obsviously i change the value for i to 1 or 2 in order to get a value. The initialization of i was missing.
I have change your programm as following, but it could certainly be done more efficient.
clc;
clear all;
global v i;
i=0;
x=[-1,1];
X=[];
Y=[];
v= 2*x;
while i<2
i=i+1;
[tempx,tempy]= ode45(@egg1a,[-1 1],[0.1]);
X=[X tempx];
Y=[Y tempy];
end
subplot(1,2,1)
plot (X(:,1),Y(:,1));
subplot(1,2,2)
plot (X(:,2),Y(:,2));
function dy =egg1a(x,y)
global v i ;
z=v(i);
dy= -z*y + x;
I am using on hold version of Matlab so you could have to do some adjustment.
Cheers,
Thomas
"Tariq " <t.umer@lancaster.ac.uk> wrote in message <hdc0mb$ic8$1@fred.mathworks.com>...
> hello dear Torsten .
> i have initialized' i' in my main function and use it in other function for getting value of v(i) and 'i' and increased the 'i' after every iteration of ode solver .
> my objective is to get the corresponding value of 'v' from the vector 'v' for every value of 'x' .
> when i run this program it gives this error.
> ??? Error using ==> odearguments at 117
> Solving EGG1A requires an initial condition vector of length 1.
>
> my program is as under.
> main program
> --------------------
> clc;
> clear all;
> global v i;
> i=i+1;
> x=[-1;1];
> v= 2*x;
> [x,y]= ode45(@egg1a,[-1 1],[0.1]);
> plot (x,y);
> --------------
> function dy =egg1a(x,y)
> global v i ;
> z=v(i);
> dy= -z*y + x;
> end
> _________________________
> some time i also get this error
> ??? Subscript indices must either be real positive
> integers or logical.
>
> can you guide me about this.
> regards
|