L型区域上特征值问题的Matlab代码

wwwo4jvm  于 2023-11-21  发布在  Matlab
关注(0)|答案(1)|浏览(284)

我有一个Matlab代码

model = createpde();
geometryFromEdges(model,@lshapeg);

applyBoundaryCondition(model,"dirichlet", ...
                             "Edge",1:model.Geometry.NumEdges, ...
                             "u",0);

specifyCoefficients(model,"m",0,"d",1,"c",1,"a",0,"f",0);

r = [0 100];

generateMesh(model,"Hmax",0.05);
results = solvepdeeig(model,r);

length(results.Eigenvalues)

u = results.Eigenvectors;
pdeplot(model,"XYData",u(:,1),"ZData",u(:,1));

字符串
当我运行这个代码几次,我得到了两个不同的图像First imageSecond image我希望得到相同的结果,我需要这个代码对我的任务特征值问题。我不知道为什么,有人可以帮助我吗?非常感谢。
我尝试访问所有函数并检查任何输入以确保一切正常。我希望得到相同的图像和特征值列表。在我的任务中,我试图获得特征值问题的近似解及其近似对应的特征值。

ckx4rj1h

ckx4rj1h1#

如果将特征向量归一化并根据特征值对其进行排序,则应在绘制数据的方向和大小方面获得一致的结果。
试试这个代码:

model = createpde();
geometryFromEdges(model, @lshapeg);

applyBoundaryCondition(model, "dirichlet", ...
    "Edge", 1:model.Geometry.NumEdges, ...
    "u", 0);

specifyCoefficients(model, "m", 0, "d", 1, "c", 1, "a", 0, "f", 0);

r = [0 100];

generateMesh(model, "Hmax", 0.05);
results = solvepdeeig(model, r);

% Sort the eigenvalues and eigenvectors
[eigenvalues, idx] = sort(results.Eigenvalues);
eigenvectors = results.Eigenvectors(:, idx);

% Normalize the eigenvectors
normalized_eigenvectors = normalize(eigenvectors);

% Plot the first eigenvector
pdeplot(model, "XYData", normalized_eigenvectors(:, 1), "ZData", normalized_eigenvectors(:, 1));

字符串

相关问题