i have this error and i can't solve it

5 views (last 30 days)
SARRA on 14 Mar 2023
Edited: Walter Roberson on 14 Mar 2023
% Représentation temps-fréquence quadratique par la distribution de Wigner-Ville
tfr1 = tfrpwv(x1.',t1);
tfr2 = tfrpwv(x2,t2);
% Affichage des résultats
title('Représentation temps-fréquence quadratique de x1(t) par la distribution de Wigner-Ville')
xlabel('Temps (s)')
title('Représentation temps-fréquence quadratique de x2(t) par la distribution de Wigner-Ville')
xlabel('Temps (s)')
Error using tfrpwv
X must have one or two columns
Jan on 14 Mar 2023
Edited: Jan on 14 Mar 2023
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.

Sign in to comment.

Answers (1)

Jan on 14 Mar 2023
Edited: Jan on 14 Mar 2023
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)
ans = 1×2
1 600
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


Community Treasure Hunt

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

Start Hunting!

Translated by