Info

此问题已关闭。 请重新打开它进行编辑或回答。

I do not know how could i change the subplot in figure 2 to look the same as figure 1

2 次查看(过去 30 天)
Hello, i am struggling to get a sinusoid like in the first Figure, the second subplot. Figure 1 is what i have to do and figure 2 is what i did. How could i change the things so it can look like that?
  2 个评论
VLADUT-VASILE HADAR
nume='Hadar';
L=length(nume);
n=50*L;
F=1;
Fs=1000;
durata=2;
t=0:1/Fs:durata;
A1=2;
s1=A1*sin(2*pi*F*t);
A2=2 ;
fi0=-pi/3;
s2=A2*sin(2*pi*F*t+fi0);
s3=A1*sin(2*pi*F*t)+A2*sin(2*pi*F*t+fi0);
figure(2)
subplot(3,1,1)
plot(t,s1,'r')
ylabel('Amplitudine')
xlabel('timp(s)')
title('Semnal s1')
ylim([-A1-0.5, A1+0.5])
grid on
subplot(3,1,2)
plot(t,s2,'m')
ylabel('Amplitudine')
xlabel('timp(s)')
title('Semnal s2')
ylim([-A2-1, A2+1])
grid on
subplot(3,1,3)
hold on
plot(t,s3)
ylabel('Amplitudine')
xlabel('timp(s)')
title('Semnal s3=s1+s2')
plot(t(n),s3(n),'^','MarkerFaceColor','g')
yline(0,'k')
hold off
I did some more than the picture above in the code but still i couldn`t change the 2nd subplot to look like in the 1st figure. I cannot get the code for that because its a .p file.

回答(1 个)

Mehmed Saad
Mehmed Saad 2020-5-5
编辑:Mehmed Saad 2020-5-5
nume='Hadar';
L=length(nume);
n=50*L;
F=1;
Fs=1000;
durata=2;
t=0:1/Fs:durata;
A1=2;
s1=A1*sin(2*pi*F*t);
A2=2 ;
fi0=-pi/3;
s2=A2*sin(2*pi*F*t+fi0);
s3=A1*sin(2*pi*F*t)+A2*sin(2*pi*F*t+fi0);
figure(2)
subplot(3,1,1)
plot(t,s1,'r')
ylabel('Amplitudine')
xlabel('timp(s)')
title('Semnal s1')
ylim([-A1-0.5, A1+0.5])
grid on
subplot(3,1,2)
plot(t,s2+1,'m')% change here
ylabel('Amplitudine')
xlabel('timp(s)')
title('Semnal s2')
ylim([-1.5 3.2]) % change here
grid on
subplot(3,1,3)
hold on
plot(t,s3)
ylabel('Amplitudine')
xlabel('timp(s)')
title('Semnal s3=s1+s2')
plot(t(n),s3(n),'^','MarkerFaceColor',[0 0.9 0],'MarkerEdgeColor',[0 0.9 0])% Change here
yline(0,'k')
hold off
  3 个评论
Mehmed Saad
Mehmed Saad 2020-5-5
编辑:Mehmed Saad 2020-5-5
Yes, 3rd subplot needs shift and rescale also. We are leaving it to you VLADUT-VASILE HADAR

此问题已关闭。

产品

Community Treasure Hunt

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

Start Hunting!

Translated by