Undefined function 'times' for input arguments of type 'cell'.

clear; clc;
syms F m w0 w
F=1.0;
m=1.0;
w0=1.0;
w=0.9;
t=0:40*pi;
y={(2*F)/(m*((w0)^2-w^2))}.*sin(((w0)+w)/2.*t).*sin(((w0)-w)/2*t);
plot(t,y)
I tried to plot this equation, but it said Undefined function 'times' for input arguments of type 'cell'. and i don't know what's wrong with it. what should i do for ploting this equation?

Antworten (1)

Stephen23
Stephen23 am 28 Mär. 2016
Bearbeitet: Stephen23 am 28 Mär. 2016
You created a cell array on this line by using the curly braces {}:
y={(2*F)/(m*((w0)^2-w^2))}.*...
If you just want to group the terms, then use standard parentheses ():
y = ((2*F)/(m*((w0)^2-w^2))) .* ...
although the rules of operator precedence show that this should work too:
y = (2*F) / (m*((w0)^2-w^2)) .* ...
Tip: too many brackets does not make code clearer, it makes it harder to read. Compare:
y = ((2*F)/(m*((w0)^2-w^2))) .* sin(((w0)+w)/2.*t).*sin(((w0)-w)/2*t);
y = (2*F) / (m*(w0^2-w^2)) .* sin((w0+w)/2.*t) .* sin((w0-w)/2*.t);

Kategorien

Mehr zu Function Creation finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 28 Mär. 2016

Bearbeitet:

am 28 Mär. 2016

Community Treasure Hunt

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

Start Hunting!

Translated by