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

Im having trouble with getting a matlab script running properly as its been a wh

ID: 2997232 • Letter: I

Question

Im having trouble with getting a matlab script running properly as its been a while since I have used MATLAB. I know its easy I just cant remember how to write scripts/functions . Here's the problem:

Write a script/function called to determine the Grashof condition of a fourbar linkage system. The program must ask the user to input a row vector containing the four link lengths and return the respective Grashof condition as a text option as "Grashof", "Special Grashof", of "Non-Grashof". 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.

A Grashof linkage is a planar four-bar linkage with

s + l < p + q

where

s = length of the shortest link
l = length of longest link
p and q are the lengths of the two remaining links.

If s + l isn't less than p + q then its non-grashof

If s + l is equal to p + q then its "special grashof"

Hers is what I have so far based off blurry memeroy of MATLAB:

L = input('link')
l = sort(L);
S=l(1);
L=l(2);
P=l(3);
Q=l(4);
if (S + L) < (P + Q)
display ('grashof')
else (S + L) > (P + Q)
display ('Non-Grashof')
end

Explanation / Answer

L=input('link');
m=sort(L);
s=m(1);
l=m(4);
p=m(3);
q=m(2);
if((s+l)<(p+q))
disp('grashof');
elseif((s+l)==(p+q))
disp('special grashof');
else
disp('non grashof');
end

input the length of links as [a b c d], as this is used to input a one dimensional vector in matlab

for example

[1 2 3 4]