Borrar filtros
Borrar filtros

What is the correct equation?

1 visualización (últimos 30 días)
Kevin Chapman
Kevin Chapman el 30 de En. de 2019
Respondida: Walter Roberson el 30 de En. de 2019
>> t=linspace(0,2*pi,100);
>> y=5*t.*(sin(t).^2)-t.^2*(cos(t).^2);
Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the
number of rows in the second matrix. To perform elementwise multiplication, use '.*'.
The equation I'm trying to input is: y=5*t*sin^2(t)-(t^2)*cos^2(t)

Respuesta aceptada

Walter Roberson
Walter Roberson el 30 de En. de 2019
y=5*t.*(sin(t).^2)-t.^2.*(cos(t).^2);
You should probably get in the habit of always using .* and .^ and ./ every time, until you finally encounter a situation where you need to use inner product * or matrix exponential ^ or least squared solutions to equations /

Más respuestas (0)

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by