Optimise comparing multidimensional matrices
古いコメントを表示
Hi. I'm trying to see where in a cell array of 21449x15, in which each cell contains a matrix of 1x7, each line of a matrix of 116255x7 occurs. Below is what I have as nested loops. It works as expected, however is obviously very slow. I'm struggling to apply any common optimisation techniques such as vectorisation or creating functions to this multidimensional problem. Would anyone have any advice please?
for i = 1:21449
% For each formula from b1 to b15
for j = 1:15
% Skip empty cases
if ~any(pep{i,j})
continue
else
% For every formula in the MFP output
for k = 1:length(formulas)
% Check if the same formula exists in the database
if isequal(formulas, pep{i,j})
% If match found, replace the formula by a score, the
% higher the number in the sequence, the higher the
% score.
result(i,j) = 1*j;
else
continue
end
end
end
end
end
2 件のコメント
Voss
2022 年 4 月 22 日
Can you upload a smaller version of your variables, say the first few hundred rows (or whatever makes sense) of pep and formulas, saved into a mat file (or two mat files)?
Also, is this line accurate as written?
if isequal(formulas, pep{i,j})
Or is it actually this?
if isequal(formulas(k,:), pep{i,j})
In any case, it would help to see (part of) the variables.
Anna
2022 年 4 月 23 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!