Multiply tall array with array
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a tall array, that contains audio samples created from a dataset like this:
dataS = tall(fileDatastore(fullfile(appData.OutputDirectoryPath, 'tmp_*.mat'), ...
'ReadFcn', @(fname) getfield(load(fname), 'resampled'), ...
'UniformRead', true));
This data is large, but its element count is known. I need to multiply this data with a signal:
t = ((0:N-1)'/fsn);
carrier = exp(1j*2*pi*carrierFreq*t);
ccy = dataS.*carrier;
The last line fails, with the following error:
Error using .*
Incompatible non-scalar tall array arguments. Each of the tall arrays must be the same size in the first dimension, must be derived from a single tall array, and must not have been indexed differently in the first
dimension (indexing operations include functions such as VERTCAT, SPLITAPPLY, SORT, CELL2MAT, SYNCHRONIZE, RETIME and so on).
I assume the issue is that it cannot guarantee that the arrays are compatible, but I can guarantee it. How can I do it?
2 commentaires
the cyclist
le 25 Avr 2024
Have you verified that the two arrays are the same size? Try putting this in your code, prior to that calculation:
size(dataS)
size(carrier)
Réponses (1)
Edric Ellis
le 29 Avr 2024
You need to use a bit of a trick to construct the colon vector. (This trick is alluded to on this doc page). Basically, you need to use find together with an element-wise expression derived from dataS such that the value of the expression is always true. This causes find to return 1:N in such a form that it can be combined with dataS. Like this:
dataS = tall(rand(1000,1));
% Use a trick to generate 1:(height(dataS))
cvec = find(true | isnan(dataS));
% Now, continue to compute t
fsn = 0.1;
t = (cvec-1) / fsn;
carrierFreq = 1000;
carrier = exp(1j*2*pi*carrierFreq*t);
gather(head(dataS .* carrier))
0 commentaires
Voir également
Catégories
En savoir plus sur Digital Filtering dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!