Write a Matlab function Fourbar (r1,r2,r3,r4,theta,speed) that animates three cycles of a fourbar linkage having link lengths r1, r2, r3, r4.
The function first checks to ensure the mechanism isGrashof (including the change-point case) and displays an error otherwise. It then checks that link 2 can make a full rotation and displays an error otherwise. The links are connected in the order 1-2-3-4-1. Link 1 is stationary and plotted horizontally, and Link 2 connects to the left side of Link 1.
The input "theta" specifies the initial angle of Link 2 relative to (stationary) Link 1. The input "speed" specifies its angular speed (in rad/s counterclockwise). The mechanism has two solutions. One solution should be animated in Figure 1, while the other is animated in Figure 2