How to plot two function multiplied by each other.

7 visualizaciones (últimos 30 días)
Payton Sanders
Payton Sanders el 26 de Abr. de 2020
Respondida: Srivardhan Gadila el 30 de Abr. de 2020
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)

Respuestas (1)

Srivardhan Gadila
Srivardhan Gadila el 30 de Abr. de 2020
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, .*

Categorías

Más información sobre Creating and Concatenating Matrices 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