Filter löschen
Filter löschen

What is the correct equation?

1 Ansicht (letzte 30 Tage)
Kevin Chapman
Kevin Chapman am 30 Jan. 2019
Beantwortet: Walter Roberson am 30 Jan. 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)

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 30 Jan. 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 /

Weitere Antworten (0)

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by