How to orientate and specify geometry location in a 3D plot?

조회 수: 4 (최근 30일)
Tom Keaton
Tom Keaton 2018년 7월 24일
편집: Tom Keaton 2018년 7월 24일
I have this script and I am plotting a magnetic field of a cylindrical magnet. I am trying to import a cylinder using the PDEs toolbox and I want to overlay the magnetic field in it. This is what I have so far. The geometry gets imported but it is not aligned and I can't figure out how to do it. Any ideas?
function [Bx,By,Bz] = bfield()
model = createpde(3);
importGeometry(model,'mag with vac space.stl');
pdegplot(model,'FaceLabels','on','FaceAlpha',0.5);
axis equal
figure
Q0 = [0 0 0;0 0 0;0 0 0];
G0 = [0 0 0];
applyBoundaryCondition(model,'neumann','Face',[1,2,3],'q',Q0,'g',G0);
applyBoundaryCondition(model,'neumann','Face',[4,5,6],'q',Q0,'g',@surfcurk);
specifyCoefficients(model,'m',0,...
'd',0,...
'c',[1;1;1],...
'a',0,...
'f',[0;0;0]);
generateMesh(model);
results = solvepde(model);
%Quiver Plot
[X,Y,Z] = meshgrid(15:0.5:25,15:0.5:25,20:0.5:40);
uintrp = interpolateSolution(results,X,Y,Z,[1,2,3]);
sol1 = reshape(uintrp(:,1),size(X));
sol2 = reshape(uintrp(:,2),size(Y));
sol3 = reshape(uintrp(:,3),size(Z));
quiver3(X,Y,Z,sol1,sol2,sol3)
axis equal
xlabel 'x'
ylabel 'y'
zlabel 'z'
title('Quiver Plot of Vector Potential Solution')
figure
[Bx,By,Bz] = curl(sol1,sol2,sol3);
quiver3(X,Y,Z,Bx,By,Bz)
axis equal
xlabel 'x'
ylabel 'y'
zlabel 'z'
title('Quiver Plot of B-Field Solution')
hold on;
%An initial attempt to import cylindrical geometry in the plot to model the physical magnet
gm = multicylinder(0.635,2.54)
model = createpde
model.Geometry = gm
pdegplot(model,'CellLabels','on')
hold off;
end
  댓글 수: 1
Tom Keaton
Tom Keaton 2018년 7월 24일
I tried setting "axis equal" for the imported STL file but it doesn't center it at all either.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Geometry and Mesh에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by