Using parfor for many expensive lsqcurvefit

1 view (last 30 days)
WahooSalty
WahooSalty on 21 May 2015
Edited: WahooSalty on 21 May 2015
Hello,
I am trying to parallelize my fitting code for the first time. I am running several hundred fits using a computationally expensive fitting function that takes a few seconds for each fit. As a test I set up a simple code but found that using either for or parfor the code took the same amount of time for any number of fits. What am I doing wrong?
clear all
close all
nu = 200:2:800;
beta = [1.5, 1.3, 520, 1, 0];
beta0 = [2, 2, 521, 1, 0];
intensity = ModelFcn(beta,nu);
betaTest = zeros(4,5);
parfor iTest = 1:4
betaTest(iTest,:) = lsqcurvefit(@ModelFcn,beta0,nu,intensity,[0 0 0 0 0],[5 5 600 2 1]);
end

Answers (0)

Community Treasure Hunt

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

Start Hunting!