Display pdeplot3D in Matlab App

조회 수: 9 (최근 30일)
Marco Mader Mendes
Marco Mader Mendes 2022년 3월 31일
댓글: xiaoli 2024년 1월 24일
Hello I want to display a pdeplot3D or a pdeplot in a Matlab App (using Matlab Appdesigner).
The Plot should be embedded in the main view and not be opend in a new Window.
To sum it up: I want to use the plot created by following command:
pdeplot3D(model,'ColorMapData',result.Stress.sxx,'Deformation',result.Displacement)
directly in Matlab Appdesigner.
The User should be able to make changes (e.q. change Boundary Conditions) and should see the newly generated plot in the App.
How can I achieve this?

채택된 답변

Kevin Holly
Kevin Holly 2022년 4월 1일
편집: Kevin Holly 2022년 4월 1일
In App Designer you need to defined the Axes. It looks like pdeplot3D does not have an input for Axes - it generates one with the newplot command. Below is a work around.
model = createpde;
importGeometry(model,'Block.stl');
applyBoundaryCondition(model,'dirichlet','Face',[1:4],'u',0);
specifyCoefficients(model,'m',0,'d',0,'c',1,'a',0,'f',2);
generateMesh(model);
results = solvepde(model);
u = results.NodalSolution;
h = pdeplot3D(model,'ColorMapData',u);
h(2).Parent = app.UIAxes;
view(app.UIAxes,45,45)
colorbar(app.UIAxes)
close(h(1).Parent)
axis(app.UIAxes,'off')
Edit: This one would be more simliar to yours since you had a transform (notice you need to change the parent of the parent of the handle rather than just the parent of the handle due to the transform).
structuralmodel = createpde('structural','static-solid');
importGeometry(structuralmodel,'SquareBeam.stl');
structuralProperties(structuralmodel,'PoissonsRatio',0.3, ...
'YoungsModulus',210E3);
structuralBC(structuralmodel,'Face',6,'Constraint','fixed');
structuralBoundaryLoad(structuralmodel,'Face',5, ...
'SurfaceTraction', ...
[0;0;-2]);
generateMesh(structuralmodel);
structuralresults = solve(structuralmodel);
figure
h = pdeplot3D(structuralmodel, ...
'ColorMapData',structuralresults.VonMisesStress, ...
'Deformation',structuralresults.Displacement)
h(2).Parent.Parent = app.UIAxes;
view(app.UIAxes2,45,45)
colorbar(app.UIAxes)
close(h(1).Parent)
axis(app.UIAxes,'off')
  댓글 수: 2
Marco Mader Mendes
Marco Mader Mendes 2022년 4월 4일
Thank you a lot for your help!
The Solution is just what I was looking for!
Thanks!
xiaoli
xiaoli 2024년 1월 24일
Thanks!
I also meet the same problem

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by