필터 지우기
필터 지우기

what is wrong in this code?

조회 수: 1 (최근 30일)
Muhammad Tarique
Muhammad Tarique 2023년 3월 12일
편집: Dyuman Joshi 2023년 3월 12일
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
Muhammad Tarique
Muhammad Tarique 2023년 3월 12일
Done
Star Strider
Star Strider 2023년 3월 12일
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.

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

채택된 답변

Dyuman Joshi
Dyuman Joshi 2023년 3월 12일
편집: Dyuman Joshi 2023년 3월 12일
@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'}
wavelets = 1×62 cell array
{'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'}
Error using vertcat
Dimensions of arrays being concatenated are not consistent.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by