Matrix Dimensions must agree

조회 수: 2 (최근 30일)
Dion Akmal
Dion Akmal 2021년 3월 24일
댓글: Dion Akmal 2021년 3월 24일
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));

답변 (1개)

Jan
Jan 2021년 3월 24일
편집: Jan 2021년 3월 24일
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
Dion Akmal
Dion Akmal 2021년 3월 24일
can you help me sir, in my code f is scalar

댓글을 달려면 로그인하십시오.

카테고리

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