I am getting the error "Dimensions of arrays being concatenated are not consistent" as mentioned in code in ECG_l calculation
Mostra commenti meno recenti
ecg_struct = load('test.mat');
fn = fieldnames(ecg_struct);
if length(fn) ~= 1
fprintf(2, 'Warning: file contains %d different variables, arbitrarily picking the first: %s\n', length(fn), fn{1});
end
ecg_i = ecg_struct.(fn{1});
s=ecg_i;
N=size(s,2);
ECG=s;
FIR_c1=[0.0041,0.0053,0.0068,0.0080,0.0081,0.0058,-0.0000,-0.0097,-0.0226,...
-0.0370,-0.0498,-0.0577,-0.0576,-0.0477,-0.0278,0,0.0318,0.0625,0.0867,...
0.1000,0.1000,0.0867,0.0625,0.0318,0,-0.0278,-0.0477,-0.0576,-0.0577,...
-0.0498,-0.0370,-0.0226,-0.0097,-0.0000,0.0058,0.0081,0.0080,0.0068,...
0.0053,0.0041];
FIR_c2=[0.0070,0.0094,0.0162,0.0269,0.0405,0.0555,0.0703,0.0833,0.0928,...
0.0979,0.0979,0.0928,0.0833,0.0703,0.0555,0.0405,0.0269,0.0162,0.0094,...
0.0070];
l1=size(FIR_c1,2);
ECG_l=[ones(1,l1)*ECG(1) ECG ones(1,l1)*ECG(N)]; %Error here
ECG=filter(FIR_c1,1,ECG_l);
ECG=ECG((l1+1):(N+l1));
How to rectify this error??
Risposte (1)
Harshit Gupta
il 21 Dic 2022
0 voti
As per my understanding, you are getting the following error while trying to run your code-
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
On running the script, it is evident that the error is due to the following line of code-
ECG_l=[ones(1,l1)*ECG(1) ECG ones(1,l1)*ECG(N)]; %Error here (line 19)
Refer to the below pointers to know how to resolve the issue:
- In line 19, you are trying to concatenate 3 different arrays:
1. ones(1,l1)*ECG(1) (It is a row vector),
2.ones(1,l1)*ECG(N) (Also a row vector),
3.ECG (A matrix of size 1280 x 18000)
- The same can be confirmed by placing a breakpoint on line 19 and then running your code. When the code execution stops at line 19, you can check the values that are contained in the 3 arrays by calling them one by one.
- Hence, to resolve the issue, you need to take care of the "ECG" array (make it a row vector only) while keeping your use case in mind.
Hope this helps!
Categorie
Scopri di più su Creating and Concatenating Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!