Promt - Write a user-defined function named Deflection_cougarnetID.m which has one input (position x) and one output, (deflection v). You will need to apply the deflection equation above with the piecewise conditions described. Use this function to determine the deflection at the position entered. Produce a formatted output to the command window that states the deflection at the point entered.
code
script- %%
choose_in = input('Please enter a psoition between 0 and 360 ');
if (choose_in < 0)
choose_in = abs(choose_in);
Warning('You entered a negative value, taking the ablsolute value');
end
if (choose_in > 360)
error('The value is greater than 360 inches, program terminated')
end
Deflection = Deflection_ahdoan2(choose_in)
function -
function [Deflection] = Deflection_ahdoan2(choose_in)
if (0<choose_in<120);
first = (choose_in);
if (120<choose_in<240)
second = (choose_in-120)
else
second = 0
if
(240<choose_in<360)
third = (choose_in-240)
else
third = 0
end
end
end
def_form = (1/3.19*10^9)*(800*choose_in^3)-(13.68*10^6*choose_in)- (2.5*choose_in^4) + 2.5*(second)^4 + 600*third^3))
end
1 Comment
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/504991-if-statements-keep-getting-error-can-someone-explain-why#comment_796181
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/504991-if-statements-keep-getting-error-can-someone-explain-why#comment_796181
Sign in to comment.