anonymous function and plotting

2 visualizaciones (últimos 30 días)
Jackson vanHerwynen
Jackson vanHerwynen el 26 de En. de 2020
Respondida: Star Strider el 26 de En. de 2020
In MATLAB, define this equation using an anonymous function, for example y(ω, x, E, I, `) = ... Then use values of ω = 2.0 kN/m, ` = 2 m, E = 70 GPa, and I = 0.00012 m4 to compute the deflection over the length of the beam. Create a plot of the deflection. Run the x-axis from 0 to 2 m and the y-axis from -0.01 to 0.01 m.
I wrote this but im confused.
y = @(w,x,E,I,l)((w*(x.^2))/(24*E*I).*((x.^2)+6*(l^2)-4*x*l));
y(2,0:.001:2,70,0.00012,2)
Im having trouble ploting this.

Respuesta aceptada

Star Strider
Star Strider el 26 de En. de 2020
You are essentially where you want to be. It helps to assign the output of your function to a different variable. (I use ‘v’ here.)
I am not certain what problems you are having with the plot call. There are two ways to plot it:
y = @(w,x,E,I,l)((w*(x.^2))/(24*E*I).*((x.^2)+6*(l^2)-4*x*l));
v = y(2,0:0.001:2,70,0.00012,2);
figure
plot(v) % Plot As A Function Of The Vector Indices
grid
figure
plot((0:0.001:2), v) % Plot As A Function Of The Vector
grid
See the documentation on plot to understand how to use it and related functions.

Más respuestas (0)

Categorías

Más información sobre Function Creation en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by