i am using the following signal as an input in a matlab code that i have made.I have put it inside the ode45 function file but the results that i am getting don't make sense. I have tried using the fixed step ode4 solver and the results are what i expect to be, but i don't want to use a fixed step solver as i don't trust them to produce accurate results.
t = linspace(0,100,10000);Fmax = 10000;ts1 = 1;ts2 = 2;ts3= 0;ts4=2;tt = ts1+ts2+ts3+ts4;n = max(size(t));Fn = zeros(1,n);for i = 1:nB = floor(t(i)/(tt));if t(i) <= (B)*tt+ts1Fn(i) =Fmax.*((t(i)-B*tt)/ts1);elseif t(i) > (B)*tt+ts1 && t(i) <= (B)*tt+ts1+ts2Fn(i) = Fmax;elseif t(i) > (B)*tt+ts1+ts2 && t(i) <= (B)*tt+ts1+ts2+ts3Fn(i) = -Fmax.*(t(i)-(ts2+ts1)-B*tt)/abs(ts3-ts2)+Fmax;elseif t(i) > (B)*tt+ts1+ts2+ts3 && t(i) < (B)*tt+ts1+ts2+ts3+ts4Fn(i) = 0;endendplot(t,Fn)
Of course inside ode function i have taken out the ''for'' part and the i.