How do I make my graph appear?

1 次查看(过去 30 天)
Nathan Formby
Nathan Formby 2019-9-21
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 个评论
Walter Roberson
Walter Roberson 2019-9-21
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)

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by