Matlab code check for signals

2 Ansichten (letzte 30 Tage)
Jone Erikson
Jone Erikson am 27 Aug. 2020
Bearbeitet: Alan Moses am 31 Aug. 2020
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.

Antworten (1)

Alan Moses
Alan Moses am 31 Aug. 2020
Bearbeitet: Alan Moses am 31 Aug. 2020
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!

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by