Why does my red lines on the graph stop?
Show older comments
For code, the red lines (vl and rvr) on the graph need to reach a certain point, which I have defined as 50, then it should remain constant. When I get the graph, the red lines stop when it reaches 50 instead of continuing constantly for the remainder of the time. How can I get the lines to show that it is constant until the end?
Any help would be greatly appreciated.
%Constants
m = 300
rw = 0.356
Iw = 2.7
N = m*9.81
Td1 = 1.134826021738053e+03
Td2 = 1200
%Magic Formula
B_1 = 10
C_1 = 1.9
D_1 = 1
E_1 = 0.97
t = [0:0.1:10]
al1= NaN(1,length(t));%empty acceleration vector
al2= NaN(1,length(t));%empty acceleration vector
vl1= NaN(1,length(t));%empty velocity vector
vl2= NaN(1,length(t));%empty velocity vector
rar1= NaN(1,length(t));%empty acceleration vector
rar2= NaN(1,length(t));%empty acceleration vector
rvr1= NaN(1,length(t));%empty velocity vector
rvr2= NaN(1,length(t));%empty velocity vector
slip1 = NaN(1,length(t));
slip2 = NaN(1,length(t));
CF_1 = NaN(1,length(t));
CF_2 = NaN(1,length(t));
vl1(1) = 0
vl2(1) = 0
rvr1(1) = 0
rvr2(1) = 0
slip1(1) = 0.16
slip2(1) = 0.16
for i = 2:100
CF_1(i) = D_1*sin(C_1*atan(B_1*slip1(i-1)-E_1*(B_1*slip1(i-1)-atan(B_1*slip1(i-1)))))
CF_2(i) = D_1*sin(C_1*atan(B_1*slip2(i-1)-E_1*(B_1*slip2(i-1)-atan(B_1*slip2(i-1)))))
al1(i) = (1/m)*(CF_1(i)*N)
al2(i) = (1/m)*(CF_2(i)*N)
vl1(i)=vl1(i-1)+al1(i)*0.1;
vl2(i)=vl2(i-1)+al2(i)*0.1;
rar1(i) = (1/Iw)*(Td1-(CF_1(i)*N*rw))*rw;
rar2(i) = (1/Iw)*(Td2-(CF_2(i)*N*rw))*rw;
rvr1(i)=rvr1(i-1)+rar1(i)*0.1;
rvr2(i)=rvr2(i-1)+rar2(i)*0.1;
if rar1(i)<0
rar1(i)=0
end
if vl1(i)>50
al1(i) = 0
vl1(i) = vl1(i-1)
rar1(i) = 0
rvr1(i) = rvr1(i-1)
end
slip1(i) = (rar1(i)-al1(i))/rar1(i)
slip2(i) = (rar2(i)-al2(i))/rar2(i)
end
figure,plot(t,vl1,'r',t,rvr1,'r',t,vl2,'b',t,rvr2,'b')
% figure,plot(t,rar1)
% figure,plot(t,slip)
% figure,plot(t,CF_1)
2 Comments
KSSV
on 16 Jun 2020
It is because, vl1 is taking a value NaN. You should recheck your code.
Charles Steyn
on 16 Jun 2020
Accepted Answer
More Answers (0)
Categories
Find more on Spline Postprocessing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!