Why is matlab unable to perform this script?
이전 댓글 표시
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
2023년 1월 10일
Please post a copy of the complete error message, which tells the readers, inwhich line the problem occurs.
Luluhihi2021
2023년 1월 10일
Benjamin Thompson
2023년 1월 10일
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.
Walter Roberson
2023년 1월 10일
MATLAB automatically transposes vectors if needed when storing them.
Luluhihi2021
2023년 1월 10일
답변 (1개)
Walter Roberson
2023년 1월 10일
P(1,:) = m.POS(:,1); P(2,:) = m.POS(:,2);
replace that with
P = m.POS(:,[1 2]).';
카테고리
도움말 센터 및 File Exchange에서 Weather and Atmospheric Science에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!