Parallel processing for asynchronous plotting
古いコメントを表示
Hello,
I have a script that plots two different 3D graphs continuously as follows:
while(condition)
mex_function() %continuous communication with a C++ MEX function, which provides the variables a, b, c, x, y, z, etc.
subplot(1,2,1)
function1(a,b,c) %simple plotting function
subplot(1,2,2)
function2(x,y,z) %time-consuming plotting function
end
Because the second subplot takes so long, and the first one needs to be updated in real time, I tried to rewrite this using parfor. These plotting functions do not interact with each other.
parfor i = 1:2
if i == 1
% code containing variables required by mex_function
while(condition)
mex_function()
f1 = figure;
function1(a,b,c)
end
else
% code containing variables required by mex_function
while(condition)
mex_function()
f2 = figure;
function2(x,y,z)
end
end
end
The MEX function saves and gets the variables using matlabPtr->setVariable(u"var_name",variable) and variable = matlabPtr->getVariable(u"variable_name"), respectively
I get the error message that my MEX function can't get the variables declared in the 'base' workspace. I am not familiar with how/where parallel workers get their variables, so does anyone have any suggestions on how to solve this issue?
As an alternative, is there a way of running two scripts completely separately in parallel?
Thank you in advance.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Parallel Computing Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!