Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Code Optimization problem and profiler question

1 vue (au cours des 30 derniers jours)
Gregory Vigil
Gregory Vigil le 18 Oct 2019
Clôturé : MATLAB Answer Bot le 20 Août 2021
I have a smoothing algorithm that I'm working on. What is the best way to optimize my code to minimize runtime? This algorithm is running over a series of 3D matrices that are at least 64x64x1000, but could potentially be even larger. I'm wondering what the fastest way to write this code since it's running over such large numbers. I've included the basic algorithm as it currently is below:
windowSize = 5;
for k = 1:numTile
for j = 1:22;
for i = 1:22;
for t = 1:endTime
first = t - windowSize;
if (first < 1)
first = 1;
end
last = t + windowSize;
if (last > endTime)
last = endTime;
end
dataArray{k}(i,j,t) = median(dataArray{k}(i,j,first:last),'omitnan');
end
dataArray{k}(i,j,:) = smooth(dataArray{k}(i,j,:),windowSize,'lowess'
end
end
end
I also have a second question. Is it possible to exlude lines from the profiler? I have several commands that require user input, and I'd prefer to exclude them so that it's easier to tell how the runtime is changing without the variability of human input.
I appreciate any help with this; I've never really optimized code before so this is kind of new territory for me. Thanks.

Réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by