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?

Réponses (1)

Stephen23
Stephen23 le 28 Mar 2016
Modifié(e) : Stephen23 le 28 Mar 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);

Catégories

En savoir plus sur Entering Commands dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by