Matlab code check for signals

조회 수: 2 (최근 30일)
Jone Erikson
Jone Erikson 2020년 8월 27일
편집: Alan Moses 2020년 8월 31일
Below is the code to Write a MATLAB function (not a script!) to generate a periodic waveform of total lengthL. Each period must be a pulse of amplitudeAthat lasts a total ofMsamples followed byT−Msamples that are zero so that the overall period isT. The result should be a squarewave.
function [y_square,n]=square(A,L,M,T)
t=0:1:T-1;
y_square1=A*(t>=0 & t<M);
stem(t,y_square1);
y_square=[];
n=[];
for i=1:L/T
y_square=[y_square y_square1];
n=[n t+10*(i-1)];
end
stem(n,y_square);
end
I am not getting any results and can't figure the error.

답변 (1개)

Alan Moses
Alan Moses 2020년 8월 31일
편집: Alan Moses 2020년 8월 31일
Hi Jone,
The code seems to be working fine. Please ensure that you have saved the file with the same name as that of your function. If you are still facing an issue, try to change the name of the function because square function is an inbuilt function in MATLAB and there might be conflict. Do make sure that the file name and function name is the same.
Hope this helps!

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by