How can I plot this anonymous function?

2 visualizzazioni (ultimi 30 giorni)
w0 = 200;
E = 200000;
I = 250.9*10^.6;
L = 6;
deflection = @(x) (w0/(120*E*I*L)).*(-(x.^5) + 2*(L.^2)*(x^.3) - (L.^4)*x);
rotation = @(x) (w0/(120*E*I*L)).*(-5*(x.^4) + 6*(L.^2)*(x^.2) - (L.^4));
derivofrotation = @(x) (w0/(120*E*I*L)).*(-20*(x.^3) + 12*(L.^2)*(x));
plot(x, rotation(x))
This is my code. When I run wihhout the plot function it raises no errors. When the plot is there the following errors are raised:
Error using ^ (line 51)
Incorrect dimensions for raising a matrix to a power.
Check that the matrix is square and the power is a
scalar. To perform elementwise matrix powers, use '.^'.
Error in
MATLAB_MAJOR>@(x)(w0/(120*E*I*L)).*(-5*(x.^4)+6*(L.^2)*(x^.2)-(L.^4))
(line 8)
rotation = @(x) (w0/(120*E*I*L)).*(-5*(x.^4) +6*(L.^2)*(x^.2) - (L.^4));
Error in MATLAB_MAJOR (line 14)
plot(x, rotation(x))
Why are these errors coming up and what can I do to stop them?

Risposta accettata

Steven Lord
Steven Lord il 17 Ott 2020
(x^.2)
You probably don't want to use the matrix power operator ^ to raise the square matrix x to the 0.2 power here. You probably want to raise each element of x to the 2nd power.
(x.^2)

Più risposte (0)

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Prodotti


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by