Interpolation error: Unable to perform assignment because the size of the left side is not the same as the size of the right side.

2 次查看(过去 30 天)
I am trying to work with a .mat file.
It contains a structure of 2 container.Map elements, one name trajs and the other emgs.
Data in emgs has a sampling frequency of 20kHz whereas data in trajs has a sampling frequency of 1kHz. As such I want to upsample the data in trajs.
trajs contains 19 cell arrays (19 keys and 19 values) with each value cell being a {680x3 double}.
I have never worked with containers.Map, cell arrays or interpolation for that matter so any help or tips would be greatly appreciated.
D = load('005_Stair11.mat');
markers = keys(D.trajs);
coords = values(D.trajs);
for i = 1:19
for j = 1:3
coords{i}(:, j) = interp(coords{i}(:, j),20);
end
end
This yiels the error 'Unable to perform assignment because the size of the left side is 680-by-1 and the size of the right side is 13600-by-1.' which I know is from the pre-determined size of the matrix but how would I go about it without having to make new matrices which as I understand is relatively time-consuming in Matlab.
  1 个评论
Adam
Adam 2019-9-25
Well, since you're increasing size from 680 to 13600 anyway I doubt resizing your existing matrix is going to be much (if any) faster than just creating a new one. You still have to assign all the new memory.
You can try inserting something like
coords{i} = zeros( 13600, 3 );
before the interp command, though I would never hard-code the size like that. More like
interpMultiple = 20;
coords{i} = zeros( size( coords{i}, 1 ) * interpMultiple, size( coords{i}, 2 ) )
but such details don't really matter if it isn't any better than simply letting it create a new matrix anyway.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Measurements and Feature Extraction 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by