Matlab under Unix vs Win?

8 visualizaciones (últimos 30 días)
sali
sali el 14 de En. de 2019
Respondida: sali el 21 de En. de 2019
Hi all,
When I run this code under Unix (Matlab 2015a), it takes forever without any result showing up, I checked the system monitor to see if the matlab is working inthe background or not I found the Matalb process is seelping as in the attached file!
I ran the same code under win (Matlab 2018), only a few minutes and I saw a msg that the matlab starts the parallel pool and it seems running , after a few minutes I received this error:
Error using rapid_accel_target_utils
Error occurred while simulating the model 'TwoVoltsTanhtestmodel2' in rapid accelerator mode. Rerun the simulation in normal mode to diagnose this
error.
Error in rapid_accel_target_utils
Error in sl (line 15)
[varargout{1:nargout}]=feval(varargin{:});
Error in testscript21 (line 121)
parfor(i = 1:numSimCmdArgStructs)
Could someone explain why this happen under Unix, although before it was fine, this is a new issue.
Thank you in advance,
The code is :
load('matlab')
mdl = 'TwoVoltsTanhtestmodel2';
%imageData=[1,-1,-1,-1,1;-1,1,-1,1,-1;-1,-1,1,-1,-1;-1,1,-1,1,-1;1,-1,-1,-1,1];
%imageData=[-1,-1,1,-1,-1;-1,-1,1,-1,-1;1,1,1,1,1;-1,-1,1,-1,-1;-1,-1,1,-1,-1];
I = imread('/home/salibensuleiman/Documents/MATLAB/Escher/Escher/DrowImg1.png');
% I1=imcomplement(I);
ResizedImage = imresize(I, [10 10]);
level = graythresh(ResizedImage);
BW = im2bw(I,level);
%A = BW(1:100,1:100);
imageData = int8(BW);
for i=1:10
for j=1:10
if(imageData(i,j)==0 )
imageData(i,j)=1;
else if ( imageData(i,j)==1)
imageData(i,j)=-1;
end
end
end
end
U=zeros(12,12);
Y=zeros(12,12);
for i=2:11
for j=2:11
U(i,j)=imageData(i-1,j-1);
end
end
PartialArray=zeros(3,3,100);
PartialY=zeros(3,3,100);
d=0;
k=1;
page=0;
for i =1:10
for j=1:10
page=page+1;
for row=i:i+2
d=d+1;
for col=j:j+2
PartialArray(d,k,page)=U(row,col);
PartialY(d,k,page)=Y(row,col);
k=k+1;
end
k=1;
end
d=0;
end
end
numParamSets = 100;
% Create parameter sets:
assignin('base',['Y11ini' ],0);
assignin('base',['Y12ini' ],0);
assignin('base',['Y13ini' ],0);
assignin('base',['Y21ini' ],0);
assignin('base',['Y22ini' ],0);
assignin('base',['Y23ini' ],0);
assignin('base',['Y31ini' ],0);
assignin('base',['Y32ini' ],0);
assignin('base',['Y33ini' ],0);
paramSets = cell(1, numParamSets);
idx = 1;
M = Simulink.BlockDiagram.buildRapidAcceleratorTarget(mdl);
for page = 1:100
paramSets{idx} = Simulink.BlockDiagram.modifyTunableParameters(...
M,...
'U11',PartialArray(1,1,page),...
'U12',PartialArray(1,2,page),...
'U13',PartialArray(1,3,page),...
'U21',PartialArray(2,1,page),...
'U22',PartialArray(2,2,page),...
'U23',PartialArray(2,3,page),...
'U31',PartialArray(3,1,page),...
'U32',PartialArray(3,2,page),...
'U33',PartialArray(3,3,page),...
'Y11ini',PartialY(1,1,page),...
'Y12ini',PartialY(1,2,page),...
'Y13ini',PartialY(1,3,page),...
'Y21ini',PartialY(2,1,page),...
'Y22ini',PartialY(2,2,page),...
'Y23ini',PartialY(2,3,page),...
'Y31ini',PartialY(3,1,page),...
'Y32ini',PartialY(3,2,page),...
'Y33ini',PartialY(3,3,page));
idx = idx+1;
end
numSimCmdArgStructs = numParamSets;
simCmdParamValStructs = cell(1, numSimCmdArgStructs);
paramValStruct.SaveTime = 'on';
paramValStruct.SaveOutput = 'on';
paramValStruct.SimulationMode = 'rapid';
paramValStruct.RapidAcceleratorUpToDateCheck = 'off';
paramValStruct.RapidAcceleratorParameterSets = [];
paramValStruct.LimitDataPoints = 'off';
idx = 1;
for paramSetsIdx = 1:numParamSets
simCmdParamValStructs{idx} = paramValStruct;
simCmdParamValStructs{idx}.RapidAcceleratorParameterSets = paramSets{paramSetsIdx};
idx = idx + 1;
end
Yout=zeros(100,1,100);
out = cell(1, numSimCmdArgStructs);
l=1;
%for l=1:2
parfor(i = 1:numSimCmdArgStructs)
out{i} = sim(mdl, simCmdParamValStructs{i});
end
for i=1:numSimCmdArgStructs
t = out{i}.find('tout');
y = out{i}.find('Y22');
PartialY(2,2,i)=y(end);
Yout(i,1,l)=y(end);
end
out = cell(1, numSimCmdArgStructs);
%end
disp('done')
fprintf('\n Contents of the out{1}: \n');
display(out{1});
displayEndOfDemoMessage(mfilename)
g=1;
% % for g=1:5
figure(g)
z=((reshape(Yout(:,:,g),[10,10])));
z1=imshow(z);
hold on;
%end
  3 comentarios
OCDER
OCDER el 15 de En. de 2019
% Create parameter sets:
assignin('base',['Y11ini' ],0);
assignin('base',['Y12ini' ],0);
assignin('base',['Y13ini' ],0);
assignin('base',['Y21ini' ],0);
assignin('base',['Y22ini' ],0);
assignin('base',['Y23ini' ],0);
assignin('base',['Y31ini' ],0);
assignin('base',['Y32ini' ],0);
assignin('base',['Y33ini' ],0);
What is the purpose of the assignin? assignin should be avoided as it's "poofing" variables into another workspace, making it difficult to debug.
Guillaume
Guillaume el 15 de En. de 2019
I've formatted the code in the question. Please learn to use the formatting tool to make your post readable.
In addition to OCDER comment, in the same lines, the [] are completely unnecessary and just visual clutter.

Iniciar sesión para comentar.

Respuesta aceptada

sali
sali el 21 de En. de 2019
Deleting the folder splrj solved this issue.

Más respuestas (1)

sali
sali el 15 de En. de 2019
Thanks Guillaume for your reply and the reformating.
Please find below the answers for your questions:
What does this mean: "although before it was fine, this is a new issue"?
I was working with this code for a while and at the begining it was running and showing me the results, recently it starts to run forever.
What do you see if you follow the advice of the message: "Rerun the simulation in normal mode to diagnose this error"?
As I understand I can not run the parfor in the normal mode, right?
What is the purpose of the assignin?
to assign an intial values for the variables Yini which are the initial values of the the outports in the simulink model.
  1 comentario
sali
sali el 15 de En. de 2019
I deleted the folder slprj, then run the code I see now in the comand window that the parallel loop started successfully, I'll wait until lthe end of the run and see.

Iniciar sesión para comentar.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by