i have this error and i can't solve it

조회 수: 11 (최근 30일)
SARRA
SARRA 2023년 3월 14일
편집: Walter Roberson 2023년 3월 14일
% Représentation temps-fréquence quadratique par la distribution de Wigner-Ville
tfr1 = tfrpwv(x1.',t1);
tfr2 = tfrpwv(x2,t2);
% Affichage des résultats
figure(1)
subplot(2,1,1)
imagesc(t1,1:length(tfr1(:,1)),abs(tfr1))
title('Représentation temps-fréquence quadratique de x1(t) par la distribution de Wigner-Ville')
xlabel('Temps (s)')
ylabel('Fréquence')
subplot(2,1,2)
imagesc(t2,1:length(tfr2(:,1)),abs(tfr2))
title('Représentation temps-fréquence quadratique de x2(t) par la distribution de Wigner-Ville')
xlabel('Temps (s)')
ylabel('Fréquence')
Error using tfrpwv
X must have one or two columns
  댓글 수: 3
SARRA
SARRA 2023년 3월 14일
편집: Walter Roberson 2023년 3월 14일
this is my code :
Fs = 16000; % fréquence d'échantillonnage: Fs >= 2*(f1+f2+f3)
T0 = 1/Fs; % pas d'échantillonnage
L = 600; % Length of signal
T = L*T0; % durée d'acquisition
t1 = 0:T0:T-T0; % vecteur temps pour x1(t)
t2_1 = 0:T0:(T/3)-T0; % vecteur temps pour x2_1(t)
t2_2 = T/3:T0:(2*T/3)-T0; % vecteur temps pour x2_2(t)
t2_3 = 2*T/3:T0:T-T0; % vecteur temps pour x2_3(t)
f0 = 300; A0 = 2; % paramètres pour x1(t)
f1 = 600; A1 = 3; % paramètres pour x1(t)
f2 = 1600; A2 = 5; % paramètres pour x1(t)
x1 = A0*sin(2*pi*f0*t1) + A1*sin(2*pi*f1*t1) + A2*sin(2*pi*f2*t1); % signal x1(t)
x2_1 = A0*sin(2*pi*f0*t2_1); % signal x2_1(t)
x2_2 = A1*sin(2*pi*f1*t2_2); % signal x2_2(t)
x2_3 = A2*sin(2*pi*f2*t2_3); % signal x2_3(t)
x2 = [x2_1 x2_2 x2_3]; % signal x2(t)
% Représentation temps-fréquence quadratique par la distribution de Wigner-Ville
figure;
subplot(2,1,1);
tfrpwv(x1,t1);
title('Distribution de Wigner-Ville de x1(t)');
subplot(2,1,2);
tfrpwv(x2,t1);
title('Distribution de Wigner-Ville de x2(t)');
and this is the error i got wheither i change the vector X or not it stays the same :
Error using tfrpwv
X must have one or two columns
or : Error using tfrpwv
Too many input arguments.
Jan
Jan 2023년 3월 14일
편집: Jan 2023년 3월 14일
Please use the tools to format code in the forum.
You still do not post the complete error message. This means everything in red and it contains the failing line also. How can you get two error messages for one code? Matlabstops after the first error message, so a code can produce one message only.

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

답변 (1개)

Jan
Jan 2023년 3월 14일
편집: Jan 2023년 3월 14일
The error message tells you: "X must have one or two columns". How many columns does your X have?
Fs = 16000; % fréquence d'échantillonnage: Fs >= 2*(f1+f2+f3)
T0 = 1/Fs; % pas d'échantillonnage
L = 600; % Length of signal
T = L*T0; % durée d'acquisition
t1 = 0:T0:T-T0; % vecteur temps pour x1(t)
t2_1 = 0:T0:(T/3)-T0; % vecteur temps pour x2_1(t)
t2_2 = T/3:T0:(2*T/3)-T0; % vecteur temps pour x2_2(t)
t2_3 = 2*T/3:T0:T-T0; % vecteur temps pour x2_3(t)
f0 = 300; A0 = 2; % paramètres pour x1(t)
f1 = 600; A1 = 3; % paramètres pour x1(t)
f2 = 1600; A2 = 5; % paramètres pour x1(t)
x1 = A0*sin(2*pi*f0*t1) + A1*sin(2*pi*f1*t1) + A2*sin(2*pi*f2*t1); % signal x1(t)
x2_1 = A0*sin(2*pi*f0*t2_1); % signal x2_1(t)
x2_2 = A1*sin(2*pi*f1*t2_2); % signal x2_2(t)
x2_3 = A2*sin(2*pi*f2*t2_3); % signal x2_3(t)
x2 = [x2_1 x2_2 x2_3]; % signal x2(t)
size(x1)
ans = 1×2
1 600
size(x2)
ans = 1×2
1 600
600 columns. This does not match the required 1 or 2 columns. The error message tells the problem clearly already.
The strategie to solve such problems is:
1. Read the documentation of the failing function:
help tfrpwv
doc tfrpwv
2. Set a break point in the code to check the dimensions of the used variables: click in the left bar in the editor in the failing line. Start the program again. When it stops at the breakpoint inspect the used variables in the WorkspaceBrowser or command window.
3. You can trigger the debugger to stop automatically at the error. Type this in the command window:
dbstop if error

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by