Plot function not working

3 次查看(过去 30 天)
shoaib Killedar
shoaib Killedar 2022-1-16
回答: KSSV 2022-1-16
if true
% code
%to generate all different waveforms
clc;
a=5;b=6;c=7;d=8;
t=0:0.01:1;
f=2;
r=0;
w=2.*pi.*f;
alpha=50;
beta=70;
m=0.5;
k=1;
X=a*sin(w*t+r);
Y=c*cos(w*t+r);
Z=c*square(w*t,alpha);
T=d*square(w*t,beta);
U=d*sawtooth(w*t,m);
N=d*sawtooth(w*t,k);
figure;
subplot(321);
plot(t,X) *bold*
title('continuous sine waveform')
xlabel('time');
ylabel('amplitude');
subplot(322);
stem(t,Y);
title('continuous cosine waveform');
xlabel('time');
ylabel('amplitude');
subplot(323);
stem(t,Z);
title('continuous square waveform');
xlabel('time');
ylabel('amplitude');
subplot(324);
stem(t,T);
title('continuous rectangular waveform');
xlabel('time');
ylabel('amplitude');
subplot(325);
stem(t,U);
title('continuous triangular waveform');
xlabel('time');
ylabel('amplitude');
subplot(326);
stem(t,N);
title('sawtooth waveform');
xlabel('time');
ylabel('amplitude');
end

回答(1 个)

KSSV
KSSV 2022-1-16
It is working fine. Copy and run like shown below:
%to generate all different waveforms
clc;
a=5;b=6;c=7;d=8;
t=0:0.01:1;
f=2; r=0;
w=2.*pi.*f;
alpha=50;
beta=70; m=0.5; k=1;
X=a*sin(w*t+r);
Y=c*cos(w*t+r);
Z=c*square(w*t,alpha);
T=d*square(w*t,beta);
U=d*sawtooth(w*t,m);
N=d*sawtooth(w*t,k);
figure;
subplot(321);
plot(t,X)
title('continuous sine waveform')
xlabel('time');
ylabel('amplitude');
subplot(322);
stem(t,Y);
title('continuous cosine waveform');
xlabel('time');
ylabel('amplitude');
subplot(323);
stem(t,Z);
title('continuous square waveform');
xlabel('time');
ylabel('amplitude');
subplot(324);
stem(t,T);
title('continuous rectangular waveform');
xlabel('time');
ylabel('amplitude');
subplot(325);
stem(t,U);
title('continuous triangular waveform');
xlabel('time');
ylabel('amplitude');
subplot(326);
stem(t,N);
title('sawtooth waveform');
xlabel('time');
ylabel('amplitude');

产品

Community Treasure Hunt

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

Start Hunting!

Translated by