Parfor error appears all of a sudden
7 views (last 30 days)
Show older comments
I am a new Matlab user. My matlab code was running perfectly fine. All of a sudden, I started getting this error:
The source code (<unknown>) for the parfor-loop that is trying to execute on the worker could not be found.
Caused by:
Unrecognized function or variable 'Flag'.
Error using remoteParallelFunction (line 84)
Worker unable to find file.
Unrecognized function or variable 'Flag'.
I wasn't getting this error on the same code previously and I haven't changed anything in my code since. I don't have any file function or variable named "Flag". Your suggestions on how to resolve this would be appreciated.
Thank you
7 Comments
Brahmadev
on 20 Sep 2023
Edited: Brahmadev
on 21 Sep 2023
Hi, could you share the data you are using or a sample of the data that is causing this issue? You mentioned that you updated the dataset, how did you do so? Manually or programmatically? I used the following random data for your code and could not reproduce the issue.
% Sample data generation
numDataPoints = 10; % Number of data points
% Generate random data for M2vwap, M2COUPON, M2stlmnt_dt, M2MATURITY, and M2INTEREST_FREQUENCY
M2vwap = rand(numDataPoints, 1);
M2COUPON = rand(numDataPoints, 1) * 10; % Assuming coupon rates between 0 and 10%
M2stlmnt_dt = datetime('today') - caldays(randi([1, 365], numDataPoints, 1)); % Random settlement dates within the last year
M2MATURITY = M2stlmnt_dt + calyears(randi([1, 10], numDataPoints, 1)); % Maturity dates are settlement dates + random number of years (1-10)
M2INTEREST_FREQUENCY =[4,3,6,12,4,12,6,1,4,3];
% Preallocate yld array
yld = zeros(numDataPoints, 1);
% Perform the calculation in parallel
parfor i = 1:numDataPoints
yld(i) = bndyield(M2vwap(i), M2COUPON(i)/100, ...
datetime(year(M2stlmnt_dt(i)), month(M2stlmnt_dt(i)), day(M2stlmnt_dt(i))), ...
datetime(year(M2MATURITY(i)), month(M2MATURITY(i)), day(M2MATURITY(i))), ...
'Period', M2INTEREST_FREQUENCY(i), 'Basis', 5);
end
% Display the calculated yields
disp(yld);
Answers (0)
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!