Create a function that generates different periodic signals
이전 댓글 표시
This is what I tried so far, but my solution doesnt seen to be working, in a plot it gives me 4 straight lines. Can someone help me find my mistake ? Thank you so so much!
function[f]=signal(s,t,A,M,T,N)
switch s
case 'Carre'
for n=1:N
S=S+(((4*A)/(N*pi))*sin((N*pi)/2)*cos(((2*N*pi)*t)./T));
end
f=M+S;
case 'Triangle'
for n=1:N
S=S+(((8*A)/(N^2*pi^2))*cos(((2*N*pi)*t)./T));
end
f=M+S;
case 'Scie'
for n=1:N
S=S+(((-1)^(N+1))*((2*A)/(N*pi))*sin(((2*N*pi)*t)./T));
end
f=M+S;
case 'Cosinus'
for n=1:N
S=S+(A*cos(((2*N*pi)*t)./T));
end
f=M+S;
otherwise
disp('Error. Name of the signal incorrectly entered.')
end
end
댓글 수: 1
Voss
2022년 2월 22일
Try changing N to n inside the for loops.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
