Why is there an error using plot?

5 visualizzazioni (ultimi 30 giorni)
Aliya Demidovich
Aliya Demidovich il 27 Gen 2021
Risposto: Walter Roberson il 27 Gen 2021
Here is my code, the graph shows nothing on it as it says there is an error using plot. Thanks for any help!
syms x
%converted to standard SI units (Newtons, Meters, rad)
L = 10;
E = 12000000000;
I = 0.001067;
w = 5000000;
y = (w/(24*E*I))*(x^4 - 4*L*(x^3) + 6*(L^2)*(x^2));
% let a=defelction, b=slope, c=moment, d=shear, e=load, ds=distance
a = y;
b = diff(y);
c = E*I*(diff(y,2));
d = E*I*(diff(y,3));
e = -E*I*(diff(y,4));
ds = linspace(0,10,0.25);
subplot(1,5,1)
plot(ds,a)
subplot(1,5,2)
plot(ds,b)
subplot(1,5,3)
plot(ds,c)
subplot(1,5,4)
plot(ds,d)
subplot(1,5,5)
plot(ds,e)

Risposte (1)

Walter Roberson
Walter Roberson il 27 Gen 2021
You first argument to plot() is numeric. When the first argument to plot() is numeric, you are using the usual plot() function (not a method of a class such as plotting a graph()). When you plot() numeric, then the other arguments to plot() must be either numeric or character vectors such as line specifications or name/value pairs. However, a, b, c, d, e are all symbolic formulas, not numeric.
You have two choices:
fplot(a, [0 10])
or
plot(ds, double(subs(a,x,ds)))

Community Treasure Hunt

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

Start Hunting!

Translated by