Matlab code check for signals

1 次查看(过去 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 中查找有关 Programming 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by