How to plot two function multiplied by each other.

9 次查看(过去 30 天)
I am attepmting to plot the functions below. I recieve the error,
"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 '.*'.
And then when I try to add the dot between my products I still recieve the error. What is the problem?
a=0;
b=3;
N=10000;
h=(b-a)/N;
t=a:h:b;
x=2000*sind(120*pi*t)*exp(-180*t)
plot(t,x)

回答(1 个)

Srivardhan Gadila
Srivardhan Gadila 2020-4-30
The output of sind(120*pi*t) & exp(-180*t) are vectors of size equal to size(t) = 1x10001.
Hence as the error indicates you to check the dimensions of matrix multiplication.
You have to use .* instead of * for element wise multiplication between two vectors having same shape.
x=2000*sind(120*pi*t).*exp(-180*t)
Refer to times, .*

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by