How to plot two function multiplied by each other.

10 ビュー (過去 30 日間)
Payton Sanders
Payton Sanders 2020 年 4 月 26 日
回答済み: Srivardhan Gadila 2020 年 4 月 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 件のコメント
darova
darova 2020 年 4 月 26 日
Please this carefully

サインインしてコメントする。

回答 (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 Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by