Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a script function called, yourlastnameGrashof, to determine the Grashof co

ID: 3750338 • Letter: W

Question

Write a script function called, yourlastnameGrashof, to determine the Grashof condition and state if input is a "crank or rocker' of a fourbar linkage system. The program must ask the user to input a row vector containing the four link lengths(input, coupler, output and ground) and return the respective Grashof condition as atext option as "Grashof ", "Special Grashof" or "Non Grashof" as well as 'input is a crank' or 'input is a rocker'. The program should output an error for an individual link length zero.

Hint: check out the MATLAB built-in function, sort(), to help sort the link lengths.

Explanation / Answer

Grashof condition : s + l <= p + q;

where special Grashof = s + l = p + q

Non Grashof = s + l > p + q

input is crank if ground is shortest

input is crank if coupler is shortest

s = shortest

l = longest

p = remaining other

q = remaining other

-------------------------------------------------------------------------------------------------

% start of the script

function Grashof = yourlastnameGrashof (input)

if(input(1) == 0 || input(2) == 0 || input(3) == 0 || input(4) == 0)

Grashof = 'error because one of the link length is zero'

else

sortedInput = sort(input)

s = sortedInput(1)

l = sortedInput(4)

p = sortedInput(2)

q = sortedInput(3)

if(s + l <= p + q)

Grashof = 'Grashof'

else

Grashof = 'Non Grashof'

end

if ((s + l == p + q) && s == p || s == q || l == p || l == q)

Grashof = 'Special Grashof'

end

if(input(4) == s)

Grashof = strcat(Grashof,' Input is crank')

elseif (input(2) == s)

Grashof = strcat(Grashof,' Input is rocker')

else

Grashof = strcat(Grashof, ' Input is crank rocker')

end

end

end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote