MATLAB Answers

0

How do I make my graph appear?

Asked by Nathan Formby on 21 Sep 2019
Latest activity Commented on by Walter Roberson
on 21 Sep 2019
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. HINT: For most of the beam, Eq. 1 results in a negative answer. This implies the deflection is in the downwards direction. TASK 3: Within your user-defined function, create a vector of values for deflection from 0 to the position entered by the user. Create a plot of the theoretical result for deflection (y axis) at each position (x axis).
Shoul also include x-axis label, y-axis label, solid line, and gridlines.
What code do I use to make the plot appear?

  1 Comment

Write a user-defined function named Deflection_cougarnetID.m
You have not done that. You have not created a function.
which has one input (position x)
You have written a script, not a function. Scripts cannot accept any input parameters.
and one output, (deflection v)
You have written a script, not a function. Scripts cannot return any values.
Within your user-defined function, create a vector of values for deflection from 0 to the position entered by the user.
You assigned
y=0:x;
which is confusing because they talk about y being the deflection, but your y is position. Furthermore, you never use your y in the calculation: the v you calculate is only at the single input position, x. You should be calculating the deflection at every value 0:x not just at x.
Remember for this purpose that the equation is piecewise, so it is a mistake to be doing the assignment y=0:x within one individual piecewise branch.
You should probably be using a for loop, something like
xinput = ...
allx = 0 : xinput;
for xidx = 1 : length(allx)
x = allx(xidx);
if (0<x)&&(x<=120)
v = formula in x
elseif (120<x)&&(x<=240)
v = second formula
end
allv(xidx) = v;
end
plot(allx, allv)

Sign in to comment.

Tags

0 Answers