Hello,
i have the following script which does a FEM for a room which is imported from GMSH.
Every function works and when i want to run the script, it won't run it. I also tried to clear the workspace but it didnt work as well.
Can anybody help?
It shows in the command window: Unable to perform assignment because the size of
the left side is 1-by-2911 and the size of the
right side is 3347-by-1.
Thank you :)
%Import Raum aus GMSH
m = load_gmsh2('MeshPJ.msh', [1 2]);
P(1,:) = m.POS(:,1); P(2,:) = m.POS(:,2);
T = m.TRIANGLES(:,1:3); GT = m.TRIANGLES(:,4);
L = m.LINES(:,1:2); GL = m.LINES(:,3);
%Aufbau Gitterstruktur
mesh = buildMesh( T,P,[],GT,L,GL );
clear m T P GT L GL
eps= 2*10^-5*ones(1,mesh.NuDoF);
index = (mesh.P(1,:)<=3.2) & (mesh.P(1,:)>=3) & (mesh.P(2,:)<=4) & (mesh.P(2,:)>=1.5);
eps(index) = 8.75*10^-7;
A = assembDiffusion2D (eps, mesh.T, mesh.P);
f =zeros(1,mesh.NuDoF);
b = assembRightSide2D(mesh, f);
%Randwerte setzen
[ A, b ] = applyDirichletBoundaryConditions(A,b, mesh, 20, @(x,y)323.13);
[ A, b ] = applyDirichletBoundaryConditions(A,b, mesh, 21, @(x,y)283.15);
u=A\b;
%Plotten
trisurf(mesh.T,mesh.P(1,:),mesh.P(2,:),u);
xlabel('x [m]'); ylabel('y [m]');zlabel('T [Kelvin]');
colormap('hot'); clim([260 330]);colorbar;

댓글 수: 5

Jan
Jan 2023년 1월 10일
Please post a copy of the complete error message, which tells the readers, inwhich line the problem occurs.
Unable to perform assignment because the size of
the left side is 1-by-2911 and the size of the
right side is 3347-by-1.
Error in PJ2_2 (line 3)
P(1,:) = m.POS(:,1); P(2,:) = m.POS(:,2);
You probably want to at least transpose m.POS before assigning it to P. Then, they are also different lengths. If you are intending to discard the extra values from m.POS, you could do:
P(1,:) = m.POS(:,1:size(P,2))'
Here, the apostrophe character is the MATLAB shorthand for transpose, to turn a column vector into a row vector.
MATLAB automatically transposes vectors if needed when storing them.
Hello,
i tried it and it gave me this error;:
Unrecognized function or variable 'P'.
Error in PJ2_2 (line 4)
P(1,:) = m.POS(:,1:size(P,2))';

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

답변 (1개)

Walter Roberson
Walter Roberson 2023년 1월 10일

0 개 추천

P(1,:) = m.POS(:,1); P(2,:) = m.POS(:,2);
replace that with
P = m.POS(:,[1 2]).';

카테고리

도움말 센터File Exchange에서 Weather and Atmospheric Science에 대해 자세히 알아보기

태그

질문:

2023년 1월 10일

답변:

2023년 1월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by