I'm trying to display a pdegplot graph in appdesigner, but I have no idea how to get it do display using app.UIAxes. My code is below

2 次查看(过去 30 天)
model = createpde;
gm = importGeometry(model,'ADCS.stl');
pdegplot(gm);

回答(2 个)

Cameron
Cameron 2022-12-30
All you have to do is put your uiaxes as the first arguement. For you, it would likely just be pdegplot(app.UIAxes,gm). Here's another example
%the code below is taken from the documation here:
%https://www.mathworks.com/help/pde/ug/pdegplot.html?s_tid=doc_ta
g = [2 1 1 1 1 1 1 1 1 4 4;
-1 -0.6 -0.5 -0.4 -0.5 0.4 0.5 0.6 0.5 -1 0.17;
1 -0.5 -0.4 -0.5 -0.6 0.5 0.6 0.5 0.4 0.17 1;
0 -0.25 -0.35 -0.25 -0.15 -0.25 -0.35 -0.25 -0.15 0 -0.74;
0 -0.35 -0.25 -0.15 -0.25 -0.35 -0.25 -0.15 -0.25 -0.74 0;
0 0 0 0 0 0 0 0 0 1 1;
1 1 1 1 1 1 1 1 1 0 0;
0 -0.5 -0.5 -0.5 -0.5 0.5 0.5 0.5 0.5 0 0;
0 -0.25 -0.25 -0.25 -0.25 -0.25 -0.25 -0.25 -0.25 0 0;
0 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 1 1;
0 0 0 0 0 0 0 0 0 0.75 0.75;
0 0 0 0 0 0 0 0 0 0 0];
pdegplot(app.UIAxes,g)
  1 个评论
Mjganji
Mjganji 2023-2-15
编辑:Mjganji 2023-2-15
I've got a syntax error with "pdegplot(app.UIAxes,g)" by:
Error using pdegplot
Expected a string scalar or character vector for the parameter name.
Is there any way to call a figure in app designer and then we write "pdegplot(g)" so it would draw in that specific figure? (like in script, "figure(F1)")

请先登录,再进行评论。


mi li
mi li 2023-6-6
I find a solution,we can copy the date of pdegplot() to app.UIAxes:
pdegplot(model);%偏微分方程求解
hFig = gcf; % 获取当前图形窗口的句柄
hAx = gca; % 获取当前坐标系的句柄
% 复制绘图对象到 app.UIAxes
copyobj(allchild(hAx), app.UIAxes);
% ylim(app.UIAxes, [-80, 0]);
% xlim(app.UIAxes, [-80, 250]);
% zlim(app.UIAxes, [-80, 80]);
view(app.UIAxes,15,25);
% 关闭图形窗口
close(hFig);

Community Treasure Hunt

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

Start Hunting!

Translated by