I've tried to set a maximum execution time for matlab function, but none of them succeeded. I have a matlab file loading a model setting from COMSOL (using COMSOL with Matlab livelink).
%filename ‘mymodel.m'
fff = 0;
store{fff+1,1} = 'out1';
store{fff+1,2} = 'out2';
for i = 1:2
for j = 1:2
fff = fff+1;
%load Model parameter setting
model_parameter_script_file
if i == 1;model.param.set('x1',val1);end
if i == 2;model.param.set('x1',val2);end
if j == 1;model.param.set('x2',val1);end
if j == 2;model.param.set('x2',val2);end
try
%load model solution script from COMSOL
model_soulution_script_file
%store table calculated from the solution into 'store'
%catch null values
catch
store{fff+1,1} = 'null';
store{fff+1,2} = 'null';
end
end
end
The issue is that I cannot figure out a way to tell the computer to terminate the for loop if anyone one of them exceeds the maximum execution time. Is it possible to do with Matlab Parallel Computing Toolbox? This could be used to accelerate program execution, but not sure if it can kill a thread when it finds that particular job exceeds the maximum running time. Thanks a lot for your help in advance.