Assurm that we just have one input-----speed .and it will between0 and 100 miles .if it is 0-25,the impression is slow that appeared in our mind ,if it is 50-75, medium ..if it is 75-100,oh ,very fasr ,we should take a higher lever brake .
we can transfer our ideas about speed into math words.Like that :
cnt = 1
for x=1:100
if x>=50
slowly(cnt,1:2)=[x, 0];
else if x>=0&&x<=25
slowly(cnt,1:2)=[x ,1];
else if x>=25&&x<=50
slowly(cnt,1:2)=[x, -0.04*x+2];
end
end
end
cnt=cnt+1
end
mnt =1
for y=1:100
if y>=50&&y<=75
medium (mnt,1:2)=[y, -0.04*y+3];
else if y>=0&&y<=25
medium(mnt,1:2)=[y ,0];
else if y>=25&&y<=50
medium(mnt,1:2)=[y, 0.04*y-1];
else if y>75
medium (mnt,1:2)=[y, 0];
end
end
end
end
mnt=mnt+1
end
bnt=1
for z=1:100
if z<=50
fast(bnt,1:2)=[z,0];
else if z>=50&&z<=75
fast(bnt,1:2)=[z 0.04*z-2];
else if z>=75
fast(bnt,1:2)=[z ,1]
end
end
end
bnt=bnt+1
end
plot(fast(:,1),fast(:,2))
hold on
plot(medium(:,1),medium(:,2))
hold on
plot(slowly(:,1),slowly(:,2))
And the graph of speed idea is
It is very simple ,hehe .the first step.
No comments:
Post a Comment