필터 지우기
필터 지우기

How Can i solve this problem

조회 수: 1 (최근 30일)
fatma karkosh
fatma karkosh 2022년 4월 14일
편집: fatma karkosh 2022년 4월 14일
T=2*pi;
ts=0.01;
t=0:ts:ts-T;
K=0:60;
N=60;
xt= 2.*sin(4*pi*t) + 5.*cos(8*pi*t);
TK=T'*K;
W=exp(-1i*2*pi/N).^TK;
x4=xt.*W;
magx4=abs(xt);
angx4=angle(xt);
figure,subplot(2,1,1);stem(magx4)
figure,subplot(2,1,2);stem(angx4);
Error using .*
Arrays have incompatible sizes for this operation.
Related documentation

채택된 답변

Riccardo Scorretti
Riccardo Scorretti 2022년 4월 14일
Hi. The problem seems to be (among others) in your definition of t. Basically, t is empty; perhaps you wanted to write T-ts as upper boundary:
T=2*pi;
ts=0.01;
% t=0:ts:ts-T; % ***
t=0:ts:T-ts;
K=0:60;
N=60;
xt= 2.*sin(4*pi*t) + 5.*cos(8*pi*t);
TK=T'*K;
W=exp(-1i*2*pi/N).^TK;
size(xt) , size(W)
ans = 1×2
1 628
ans = 1×2
1 61
The following lines generated the error, because the sizes of xt and W are different. By the way, you don't need x4 in the rest of the code you posted.
In order to give you a better help, it would be necessary to know with more detail what is the problem you are solving, so that it is possible to have a better understanding of the algorithm you are trying to implement.
% x4=xt.*W;
magx4=abs(xt);
angx4=angle(xt);
figure,subplot(2,1,1);stem(magx4)
figure,subplot(2,1,2);stem(angx4);
Finally, I suggest you to be more specific in the text of your message: "How can I solve this problem" is too generic, and doesn't help. For instance, in this case you could use "Problem with multiplication of variables of different sizes" (this is just my personal point of view).
  댓글 수: 1
fatma karkosh
fatma karkosh 2022년 4월 14일
편집: fatma karkosh 2022년 4월 14일
thank you so much for your helping.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by