Function won't show up on plot

1 回表示 (過去 30 日間)
Armin Kaufmann
Armin Kaufmann 2019 年 9 月 30 日
回答済み: Jyotsna Talluri 2019 年 10 月 3 日
Hi, so I'm supposed to create a rectangular signal (with 1 period) that looks as the screenshot posted:graph.png
where I have 4 input parameters: "T" as the period input in seconds, "Ti" as the duty cycle input in seconds too, H as the "High" - Level of the signal and L as the "Low" - Level of the signal.
So, I created a function to achieve that:
function [yg, t] = Task1Try2(T,Ti,H,L,N)
yges=L:H;
for t=1:T
if t<Ti
yges=ones*H
else
yges=ones*L
end
end
yg=yges;
plot(t,yg);
title("Muster");
xlabel("Zeit in S");
ylabel("Amplitude");
grid on
axis([0,T,0,5]);
end
By the way idk how to put matlab code in here as smooth in those "boxes", feel free 2 let me know.
I have a suspicion that the problem is that I do not assign each "t" value with a proper "y"/"yges" value, but how do I get that done? I don't want the Y values changed by the t value so....
Thanks in advance!

回答 (1 件)

Jyotsna Talluri
Jyotsna Talluri 2019 年 10 月 3 日
For creating the rectangular pulse waveform, there is an inbuilt function phased.RectangularWaveform in Phased Array System Toolbox .You can try using that
waveform=phased.RectangularWaveform('PulseWidth',Ti,'PRF',1/T,'OutputFormat','Pulses','NumPulses',N);
y=waveform();
y=(b-a)*y;
du = N*1/waveform.PRF;
tsam = du*waveform.SampleRate;
t = unigrid(0,1/waveform.SampleRate,du,'[)');
plot(t.*1000,real(y)+a);
Refer to the below link for more information

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by