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 Center および File ExchangeWaveform Generation についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by