Vectors must be the same length.

조회 수: 1 (최근 30일)
toqa Ayman
toqa Ayman 2021년 6월 2일
댓글: Stephan 2021년 6월 3일
t=0:0.01:1;
fc=60;
fm=15;
ac=1;
am=1;
wc=2*pi*fc;
wm=2*pi*fm;
mt=am*cos(wm*t);
m_ac=ac*cos(wc*t);
%mssb=mt*cos(2*pi*(fc-fm)t)-.*cos(2*pi(fc+fm)*t;
%mssb=ac*sin(wc)+(m*ac/2).*cos(wc-wm)-(m*ac/2).*cos(wc+wm);
xssb=mt.*cos(wc*t)+(mt.*sin(wc*t));
wc=2*pi*fc;
wm=2*pi*fm;
mt=am*cos(wm*t);
sc=ac*cos(wc*t);
xam=am*cos(wm*t).*cos(wc*t);
x_vsb=(xssb+xam)/2;
n=256;
fs=3*fc;
%vm=cos(wm*t);
mt_fssb=fft(xssb,n);
%fft_vm=abs(fft_vm(1:length(fft_vm)/2+1));
fssb=[-(length(mt_fssb))/2:(length(mt_fssb))/2-1]*fs/length(mt_fssb);
mt_amdsb=fft(xam,n);
fdsb=[-(length(mt_amdsb))/2:(length(mt_amdsb))/2-1]*fs/length(mt_amdsb);
mt_vsb=fft(x_vsb,n);
f_vsb=[-(length(mt_vsb))/2:(length(mt_vsb))/2-1]*fs/length(mt_vsb);
fo=45;
wo=2*pi*fo;
w=2*pi*f_vsb;
n1=8;
m=2*n1;
wf=w/wo;
wf2=wf.^m;
wf3=sqrt(1+wf2);
hw=(1./wf3);
%hw=1/(sqrt(1+(w1/wo)^(2*n)));
dm_vsb=mt_vsb.*hw;
subplot(2,2,1);
plot(t,abs(x_vsb));
title('vsb domain w');
xlabel('Time');
ylabel('Amplitude');
length (f_vsb);
length (mt_vsb);
length (abs(x_vsb));
subplot(2,2,2);
plot3(f_vsb,mt_vsb,abs(x_vsb));
title('vsb domain f');
xlabel('Frequency');
ylabel('Amplitude');
subplot(2,2,3);
plot(f_vsb,hw);
title('Filter');
xlabel('Frequency');
ylabel('Amplitude');
subplot(2,2,4);
plot(f_vsb,abs(mt_vsb));
title('demodulation');
xlabel('Frequency');
ylabel('Amplitude');
Error using plot3
Vectors must be the same length.
Error in Untitled2 (line 60)
plot3(f_vsb,mt_vsb,abs(x_vsb));

답변 (1개)

Stephan
Stephan 2021년 6월 2일
편집: Stephan 2021년 6월 2일
Change line 1:
t=linspace(0,1,256);
fc=60;
fm=15;
ac=1;
am=1;
wc=2*pi*fc;
wm=2*pi*fm;
mt=am*cos(wm*t);
m_ac=ac*cos(wc*t);
%mssb=mt*cos(2*pi*(fc-fm)t)-.*cos(2*pi(fc+fm)*t;
%mssb=ac*sin(wc)+(m*ac/2).*cos(wc-wm)-(m*ac/2).*cos(wc+wm);
xssb=mt.*cos(wc*t)+(mt.*sin(wc*t));
wc=2*pi*fc;
wm=2*pi*fm;
mt=am*cos(wm*t);
sc=ac*cos(wc*t);
xam=am*cos(wm*t).*cos(wc*t);
x_vsb=(xssb+xam)/2;
n=256;
fs=3*fc;
%vm=cos(wm*t);
mt_fssb=fft(xssb,n);
%fft_vm=abs(fft_vm(1:length(fft_vm)/2+1));
fssb=[-(length(mt_fssb))/2:(length(mt_fssb))/2-1]*fs/length(mt_fssb);
mt_amdsb=fft(xam,n);
fdsb=[-(length(mt_amdsb))/2:(length(mt_amdsb))/2-1]*fs/length(mt_amdsb);
mt_vsb=fft(x_vsb,n);
f_vsb=[-(length(mt_vsb))/2:(length(mt_vsb))/2-1]*fs/length(mt_vsb);
fo=45;
wo=2*pi*fo;
w=2*pi*f_vsb;
n1=8;
m=2*n1;
wf=w/wo;
wf2=wf.^m;
wf3=sqrt(1+wf2);
hw=(1./wf3);
%hw=1/(sqrt(1+(w1/wo)^(2*n)));
dm_vsb=mt_vsb.*hw;
subplot(2,2,1);
plot(t,abs(x_vsb));
title('vsb domain w');
xlabel('Time');
ylabel('Amplitude');
length (f_vsb);
length (mt_vsb);
length (abs(x_vsb));
subplot(2,2,2);
plot3(f_vsb,mt_vsb,abs(x_vsb));
Warning: Imaginary parts of complex X, Y, and/or Z arguments ignored
title('vsb domain f');
xlabel('Frequency');
ylabel('Amplitude');
subplot(2,2,3);
plot(f_vsb,hw);
title('Filter');
xlabel('Frequency');
ylabel('Amplitude');
subplot(2,2,4);
plot(f_vsb,abs(mt_vsb));
title('demodulation');
xlabel('Frequency');
ylabel('Amplitude');
  댓글 수: 2
toqa Ayman
toqa Ayman 2021년 6월 2일
Thank you
Stephan
Stephan 2021년 6월 3일
Did you notice that you can accept and/or vote for useful answers?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by