How do at write the equation

1 visualización (últimos 30 días)
Anna Nordin
Anna Nordin el 3 de Sept. de 2019
Comentada: Torsten el 3 de Sept. de 2019
How do I make this equation work for a vector? (the vector x=[-1:0.1:1])
f = x 2 sin(πx)
I've tried the following:
f=x.^2*sin(x.*pi)
f=x.^2*sin(x*pi)
It doesn't work.

Respuesta aceptada

Torsten
Torsten el 3 de Sept. de 2019
f = x.^2.*sin(x*pi)
  2 comentarios
Anna Nordin
Anna Nordin el 3 de Sept. de 2019
Thank you!
I thought you only had to pun "." after the x
Torsten
Torsten el 3 de Sept. de 2019
No. As soon as you multiply vectors elementwise, you have to use the ".*", "./", ".^" operators.
x.^2 is a vector, sin(pi*x) is a vector. To multiply them elementwise, you have to use ".*" .

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by