How do I rectify the error corresponding to the Dimensions of arrays being concatenated no being consistent

2 Ansichten (letzte 30 Tage)
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));
  1 Kommentar
Stephen23
Stephen23 am 15 Dez. 2022
Bearbeitet: Stephen23 am 15 Dez. 2022
The data you uploaded has size 1200x18000, but your code:
ECG_l=[ones(1,l1)*ECG(1) ECG ones(1,l1)*ECG(N)];
is unclear, what you expect to occur. ECG(1) and ECG(N) will be scalars, but because N is the number of columns which you then use as a linear index it will select... element (80,15). Very unusual, and most likely not what you intended.
Then you concatenate horizontally, but with two row vectors: what do you expect to occur when you concatenate such arrays horizontally together?:
[1x18000, 1280x18000, 1x18000] % not possible: the number of rows are different
PS: why do you need three different names for exactly the same thing?:
ecg_i = ecg_struct.(fn{1});
s=ecg_i;
ECG=s;

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Stephen23
Stephen23 am 15 Dez. 2022
Making a wild guess about the wanted output array size:
ECG_l = ECG([1,1:end,end],:);

Weitere Antworten (0)

Kategorien

Mehr zu Language Fundamentals finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by