error code using pdeplot function.

4 Ansichten (letzte 30 Tage)
Shikun Nie
Shikun Nie am 18 Feb. 2022
Beantwortet: SAI SRUJAN am 28 Dez. 2023
My code is as below. Some of the functions are defined in separate files not shown here.
tiledlayout(3,2);
load("video.mat");
msh1.P=P;
msh1.E=E;
msh1.T=T;
Mbar1 = discretiseLinearElasticity(msh1);
nexttile;
pdemesh(msh1.P,msh1.E,msh1.T);
axis equal;
nexttile;
spy(Mbar1);
load("kiwi.mat");
msh2.P=P;
msh2.E=E;
msh2.T=T;
Mbar2 = discretiseLinearElasticity(msh2);
nexttile;
pdemesh(msh2.P,msh2.E,msh2.T);
axis equal;
nexttile;
spy(Mbar2);
u = sin(msh2.P(1,:)).*cos(msh2.P(2,:));
norm = (u * Mbar2 * u')^0.5;
disp(norm);
nexttile;
pdeplot(msh2.P,msh2.E,msh2.T,'ZData', u);
The error is as follows. But the plot did appear to be correct after execution. Basically I don't know what causes this error.
Error using matlab.graphics.layout.TiledChartLayout/set
Unrecognized property currentaxes for class TiledChartLayout.
Error in pdeplot (line 1142)
set(get(ax,'parent'),'currentaxes',ax)
Error in hw5 (line 27)
pdeplot(msh2.P,msh2.E,msh2.T,'ZData', u);
  2 Kommentare
KSSV
KSSV am 18 Feb. 2022
What version of MATLAB you are using?
What does
which tiledlayout
/MATLAB/toolbox/matlab/graphics/tiledlayout.p
show up for you?
Note that this option is available from 2019b.
Shikun Nie
Shikun Nie am 18 Feb. 2022
I am using R2021b.
>> which tiledlayout
C:\Program Files\MATLAB\R2021b\toolbox\matlab\graphics\tiledlayout.p

Melden Sie sich an, um zu kommentieren.

Antworten (1)

SAI SRUJAN
SAI SRUJAN am 28 Dez. 2023
Hi Shikun,
I understand that you are facing an issue using 'pdeplot' function in 'tiledlayout'.
'pdeplot' is a function in MATLAB used to plot the results of a PDE (Partial Differential Equation) solution, such as the geometry, mesh, and contours of the solution. When we want to include a 'pdeplot' in a 'tiledlayout', we can do so by creating the tiled layout first and then specifying the axes handle where the 'pdeplot' should be drawn.
Follow the given code snippet to proceed further,
figure;
% Create a tiledlayout to manage the layout of multiple plots.
tiledlayout(2, 1);
% Create an axes object within the tiledlayout using the nexttile function.
ax1 = nexttile;
model = createpde;
geometryFromEdges(model,@lshapeg);
mesh = generateMesh(model);
% Call pdeplot and specify the axes handle to draw the plot in the correct tile.
pdeplot(mesh, 'Parent', ax1);
ax2 = nexttile;
plot([1:100]);
The 'pdeplot' function uses the 'Parent' property to specify where the plot should appear.
For a comprehensive understanding of the 'tiledlayout' and 'pdeplot' function in MATLAB, please refer to the following documentation.
I hope this helps.

Tags

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by