How to make PDE toolbox continue running for all iterations?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
GHULAM RASOOL
am 9 Aug. 2016
Kommentiert: Yoshihiro
am 27 Feb. 2020
Hi, I have managed to get the PDE toolbox run in loop. However after each iteration the PDE toolbox gives message to save changes or cancel before jumping on to the next iteration. I don't want this dialogue box to appear as I have to click through it everytime. Is there to automatically run loop itself without human intervention. Any help much appreciated. Below is the code:
for j = 1:5
w = j*2;
wstring = num2str(w);
sinstring = strcat('sin(',wstring,'*t)')
[pde_fig,ax]=pdeinit;
pdetool('appl_cb',9);
set(ax,'DataAspectRatio',[1 2 1]);
set(ax,'PlotBoxAspectRatio',[1 0.66666666666666663 1.3333333333333333]);
set(ax,'XLim',[0 1.5]);
set(ax,'YLim',[0 2]);
set(ax,'XTickMode','auto');
set(ax,'YTickMode','auto');
% Geometry description:
pderect([0 1 1 0],'R1');
set(findobj(get(pde_fig,'Children'),'Tag','PDEEval'),'String','R1')
pdetool('changemode',0)
pdesetbd(4,...
'neu',...
1,...
'0',...
sinstring)
pdesetbd(3,...
'neu',...
1,...
'0',...
'0')
pdesetbd(2,...
'neu',...
1,...
'0',...
'0')
pdesetbd(1,...
'neu',...
1,...
'0',...
'0')
% Mesh generation:
setappdata(pde_fig,'Hgrad',1.3);
setappdata(pde_fig,'refinemethod','regular');
setappdata(pde_fig,'jiggle',char('on','mean',''));
setappdata(pde_fig,'MesherVersion','preR2013a');
pdetool('initmesh')
pdetool('refine')
% PDE coefficients:
pdeseteq(2,...
'1.0',...
'1.0',...
'(0)+(1.0).*(0.0)',...
'(1.0).*(1.0)',...
'(0:0.01:20)',...
'0.0',...
'0.0',...
'[0 100]')
setappdata(pde_fig,'currparam',...
['1.0';...
'1.0';...
'1.0';...
'0 ';...
'1.0';...
'0.0'])
% Solve parameters:
setappdata(pde_fig,'solveparam',...
char('0','1362','10','pdeadworst',...
'0.5','longest','0','1E-4','','fixed','Inf'))
% Plotflags and user data strings:
setappdata(pde_fig,'plotflags',[1 1 1 1 1 1 1 1 0 0 0 2001 1 0 0 0 0 1]);
setappdata(pde_fig,'colstring','');
setappdata(pde_fig,'arrowstring','');
setappdata(pde_fig,'deformstring','');
setappdata(pde_fig,'heightstring','');
% Solve PDE:
pdetool('solve')
end
0 Kommentare
Akzeptierte Antwort
Alan Weiss
am 9 Aug. 2016
Bearbeitet: Alan Weiss
am 9 Aug. 2016
I think that you would do yourself a favor by learning to use command-line functions instead of relying on the PDE app. Depending on your MATLAB version, you might be able to use the following instead of your current app-based script, at least in part.
model = createpde();
gd = [3,4,0,1,1,0,0,0,1,1]'; % square geometry
dl = decsg(gd);
geometryFromEdges(model,dl); % include geometry
generateMesh(model,'Hmax',0.1);
specifyCoefficients(model,'m',0,'d',1,'c',2,'a',1,'f',0);
setInitialConditions(model,0);
tlist = 0:0.01:100; % do you really need such fine spacing?
for j = 1:5
gfun = @(region,state)sin(2*j*state.time); % one nondefault condition
applyBoundaryCondition(model,'neumann','edge',4,'g',gfun);
result{j}=solvepde(model,tlist); % save all results in a cell array
delete(model.BoundaryConditions); % prepare for next loop
end
To see a plot of the first loop at the 500th time point:
pdeplot(model,'xydata',result{1}.NodalSolution(:,500))
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
5 Kommentare
Alan Weiss
am 10 Aug. 2016
I don't know how to do that, sorry.
Alan Weiss
MATLAB mathematical toolbox documentation
Yoshihiro
am 27 Feb. 2020
Looks like this is an old post, but you can just use
close all force
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Geometry and Mesh finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!