ode23 calling and speicified time problems

2 views (last 30 days)
sarngon
sarngon on 23 Feb 2012
hello,
i have a prog. below
*global Ua Ub
Ua=3; Ub=0;
[t,x]=ode23('train',[0,5],[0;0]);
subplot(3,1,1);plot(t,x(:,1));ylabel('displacement');xlabel('second'); grid on
subplot(3,1,2);plot(t,x(:,2)); ylabel('velocity');xlabel('second'); grid on*
now my question is that there is a train function in my program and olsa in this function i use Ua and Ub as a global variable. But Ua not a constant afer 5 second it is changing to 5 for example and i have to call ode23 to solve it again with a new value of Ua .
Now here some problems.
the first problem is initial value prblem because for example time between 0 and 5 second Ua=3 at t =5 there is a output x(:,1)=20 and when i change ua=5 i call it ode23 again like
[t,x]=ode23('train',[now here 5to10],[now i should write here fisrt ode23 solution x(:,1) last value as a initial value and x(:,2) too but i cannot find them without counting hw many value for ex last vluae x(31,1) ]
as a result , I CANNOT USE LAST VALUE OF RESULT OF FİRST ODE23 SOLUTION AND I CANNOT PLOT THE WHOLE VALUE WİTH PLOT(T,X(:,1)) COMMAND BECAUSE İT TAKES LAST VALUE OF ODER23 NOT T[0,5] ONLY T[5-10]
HOW CAN I HANDLE ??
THANKS FOR YOUR HELP

Answers (0)

Community Treasure Hunt

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

Start Hunting!