Matrix Dimensions must agree

please help me im new at using MATLAB
here is my code
f = 0.05:0.05:0.4;
t = 0:0.01:20;
g = dot(cos(2*pi.*f.*t),sin(2*pi.*f.*t));
and the error is
Matrix dimensions must agree.
g = dot(cos(2*pi.*f.*t),sin(2*pi.*f.*t));

Respuestas (1)

Jan
Jan el 24 de Mzo. de 2021
Editada: Jan el 24 de Mzo. de 2021

0 votos

f and t have a different number of elements. Then f .* t is not defined.
You did not tell us, what you want to achieve, but perhaps transposing one of the vectors will do what you want:
g = dot(cos(2*pi * f .* t.'), sin(2 * pi * f .* t.'));
% ^^ ^^
Try this:
x = 1:3
y = 4:7
x .* y % error
x .* y.' % matrix

1 comentario

Dion Akmal
Dion Akmal el 24 de Mzo. de 2021
can you help me sir, in my code f is scalar

Iniciar sesión para comentar.

Categorías

Etiquetas

Preguntada:

el 24 de Mzo. de 2021

Comentada:

el 24 de Mzo. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by