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 visualizzazioni (ultimi 30 giorni)
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 Commento
Adam
Adam il 25 Set 2019
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.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Measurements and Feature Extraction in Help Center e File Exchange

Prodotti


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by