what is wrong in this code?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Muhammad Tarique
il 12 Mar 2023
Modificato: Dyuman Joshi
il 12 Mar 2023
load('matlab.mat', 'voltage');
level = 6;
wavelets = {'haar','db1', 'db2', 'db3', 'db4', 'db5', 'db6', 'db7', 'db8', 'db9', 'db10','sym2', 'sym3', 'sym4', 'sym5', 'sym6', 'sym7', 'sym8', 'sym9',
'sym10','coif1', 'coif2', 'coif3', 'coif4', 'coif5', 'bior1.1', 'bior1.3', 'bior1.5', 'bior2.2', 'bior2.4', 'bior2.6', 'bior2.8', 'bior3.1', 'bior3.3', 'bior3.5',
'bior3.7', 'bior3.9', 'bior4.4', 'bior5.5', 'bior6.8','rbior1.1', 'rbior1.3', 'rbior1.5', 'rbior2.2', 'rbior2.4', 'rbior2.6', 'rbior2.8', 'rbior3.1', 'rbior3.3', 'rbior3.5', 'rbior3.7', 'rbior3.9', 'rbior4.4', 'rbior5.5', 'rbior6.8', 'dmey', 'fk4', 'fk6', 'fk8', 'fk14', 'fk18', 'fk22'};
SD = zeros(1, length(wavelets)); % preallocate SD vector with zeros
for i = 1:length(wavelets)
% Perform wavelet decomposition
[c,l] = wavedec(voltage, level, wavelets{i});
% Extract detail coefficients from level 6
details = detcoef(c,l,6);
% Calculate standard deviation of detail coefficients
SD(i) = std(details);
end
% Display the results
disp(SD)
Error
Dimensions of matrices being concatenated are not consistent.
Dimensions of matrices being concatenated are not consistent.
3 Commenti
Star Strider
il 12 Mar 2023
I do not see that you are concatenating any matrices in the posted code.
The error (in most instances) will also display the line of code throwing the error, or at least refer to it. Please show that line of code as well.
Risposta accettata
Dyuman Joshi
il 12 Mar 2023
Modificato: Dyuman Joshi
il 12 Mar 2023
@Muhammad Tarique, as Jan and Star Strider asked for - the full error message, which means all of the red text. Please keep that in mind.
For the error - You need to use ellipses (...) to continue the statement for defining the variable wavelets
%Go to the end of first two lines to see the usage of ellipses
wavelets = {'haar','db1', 'db2', 'db3', 'db4', 'db5', 'db6', 'db7', 'db8', 'db9', 'db10','sym2', 'sym3', 'sym4', 'sym5', 'sym6', 'sym7', 'sym8', 'sym9', ...
'sym10','coif1', 'coif2', 'coif3', 'coif4', 'coif5', 'bior1.1', 'bior1.3', 'bior1.5', 'bior2.2', 'bior2.4', 'bior2.6', 'bior2.8', 'bior3.1', 'bior3.3', 'bior3.5', ...
'bior3.7', 'bior3.9', 'bior4.4', 'bior5.5', 'bior6.8','rbior1.1', 'rbior1.3', 'rbior1.5', 'rbior2.2', 'rbior2.4', 'rbior2.6', 'rbior2.8', 'rbior3.1', 'rbior3.3', 'rbior3.5', 'rbior3.7', 'rbior3.9', 'rbior4.4', 'rbior5.5', 'rbior6.8', 'dmey', 'fk4', 'fk6', 'fk8', 'fk14', 'fk18', 'fk22'}
If you don't use ellipses, entering data in the next line is treated as next row, and in the manner you have written, the number of elements in each line are not same, thus you get the error for vertical concatenation.
%Example of the error
alphabet = {'a',
'b', 'c',
'd', 'e', 'f'}
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Signal Radiation and Collection in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!