I tried setting "axis equal" for the imported STL file but it doesn't center it at all either.
How to orientate and specify geometry location in a 3D plot?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
Réponses (0)
Voir également
Catégories
En savoir plus sur Geometry and Mesh dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!