필터 지우기
필터 지우기

Create a matrix that contains sine wave

조회 수: 18 (최근 30일)
Mohammed Magdy Sharara
Mohammed Magdy Sharara 2018년 10월 22일
답변: Akira Agata 2018년 10월 22일

Define a 5xN matrix such that each row of the matrix contains a sine wave with a frequency equal to the row number. (0 < t < 1).

I am doing the matrix of zeros thingie but it keeps telling me an error

t=0:0.001:1; x=zeros(5,length(t)); for i=1:length(t) x(i)=sin(2.*pi.*i.*t) end

can any body help ?

답변 (2개)

Erivelton Gualter
Erivelton Gualter 2018년 10월 22일
Try this:
t=0:0.001:1;
x=zeros(5,length(t));
for fi=1:5
for i=1:length(t)
x(fi,i)=sin(2*pi*fi*t(i));
end
end
  댓글 수: 1
madhan ravi
madhan ravi 2018년 10월 22일
+1 vote crystal clear @Erivelton

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


Akira Agata
Akira Agata 2018년 10월 22일
You can avoid for-loop by simply:
t = 0:0.001:1;
f = 1:5;
x = sin(2*pi*f'*t);

카테고리

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

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by