How do I rectify the error corresponding to the Dimensions of arrays being concatenated no being consistent
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Stephen23
2022-12-15
编辑:Stephen23
2022-12-15
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;
采纳的回答
Stephen23
2022-12-15
Making a wild guess about the wanted output array size:
ECG_l = ECG([1,1:end,end],:);
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!