Clear Filters
Clear Filters

What is the correct equation?

1 view (last 30 days)
>> 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)

Accepted Answer

Walter Roberson
Walter Roberson on 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 /

More Answers (0)

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!