Display pdeplot3D in Matlab App

13 vues (au cours des 30 derniers jours)
Marco Mader Mendes
Marco Mader Mendes le 31 Mar 2022
Commenté : xiaoli le 24 Jan 2024
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?

Réponse acceptée

Kevin Holly
Kevin Holly le 1 Avr 2022
Modifié(e) : Kevin Holly le 1 Avr 2022
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 commentaires
Marco Mader Mendes
Marco Mader Mendes le 4 Avr 2022
Thank you a lot for your help!
The Solution is just what I was looking for!
Thanks!
xiaoli
xiaoli le 24 Jan 2024
Thanks!
I also meet the same problem

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by