How to make Matlab to wait until the PDE toolbox computes the solution?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to extract mesh and solution data using script from the PDE toolbox however, when i run the following script the code does provide the pde solution but it doesn't seem to extract the data which might be because it doesn't wait for GUI to complete. However, when I run the commands to extract the data separately after i get the PDE solution it does work but that would meaning running the extraction commands separately in another script or in the workspace. Therefore, I want to incorporate everything in one script and it should provide PDE solution and data in single run.
function pdemodel
[pde_fig,ax]=pdeinit;
pdetool('appl_cb',9);
set(ax,'DataAspectRatio',[1 1.5 1]);
set(ax,'PlotBoxAspectRatio',[1 0.66666666666666663 1]);
set(ax,'XLim',[0 2]);
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')
% Boundary conditions:
pdetool('changemode',0)
pdesetbd(4,...
'neu',...
1,...
'0',...
'sin(2*t)')
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',''));
pdetool('initmesh')
pdetool('refine')
% PDE coefficients:
pdeseteq(2,...
'1.0',...
'0',...
'(0)+(0).*(0.0)',...
'(1.0).*(1.0)',...
'0:0.1:10',...
'0.0',...
'0.0',...
'[0 100]')
setappdata(pde_fig,'currparam',...
['1.0';...
'1.0';...
'1.0';...
'0 ';...
'0 ';...
'0.0'])
% Solve parameters:
setappdata(pde_fig,'solveparam',...
str2mat('0','1872','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 101 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')
function [p,e,t,u] = getpetu
%GETPETU Get p,e,t,and u.
pde_fig=findobj(allchild(0),'flat','Tag','PDETool');
if isempty(pde_fig)
error('PDE Toolbox GUI not active.')
end
u = get(findobj(pde_fig,'Tag','PDEPlotMenu'),'UserData');
h=findobj(get(pde_fig,'Children'),'flat','Tag','PDEMeshMenu');
hp=findobj(get(h,'Children'),'flat','Tag','PDEInitMesh');
he=findobj(get(h,'Children'),'flat','Tag','PDERefine');
ht=findobj(get(h,'Children'),'flat','Tag','PDEMeshParam');
p=get(hp,'UserData');
e=get(he,'UserData');
t=get(ht,'UserData');
2 Kommentare
Walter Roberson
am 5 Jun. 2016
When I scan the code, I do not seem to find the point at which the data is being extracted?
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!