The uiload call is going to prompt the user to select a file, and then it is going to guide the user to import variables from the file. In particular variables named x, y, and z are expected to be loaded by the statement. There are a variety of file formats that would be supported by the call; the easiest of them would be if the user selects a .mat file that contains variables named x, y, and z
quenstion about uiload in matlab
6 次查看(过去 30 天)
显示 更早的评论
i come cross this file online and i dont understand what is "uiload" use for in this situation
can anybody explain this pls? and what kind of file should it be?
clear
%Load vector for coils with three separate components: x, y and z
uiload
clc
vector=[x,y,z];
%Define range of computation
maxx=1.01.*max(x);
minx=1.01.*min(x);
maxy=1.01.*max(y);
miny=1.01.*min(y);
maxz=1.01.*max(z);
minz=1.01.*min(z);
%define number of divisions between min and max range
pts=input('Define number of divisions of grid:');
%Define Vertical position of horizontal plane for evaluation, center=0.
zplane=input('Define Z-Plane on which to compute: (numeric) ');
%The next block of code generates an array of computation points
stepx=(maxx-minx)/pts;
stepy=(maxy-miny)/pts;
stepz=(maxz-minz)/pts;
for p=0:pts
ex(p+1)=minx+stepx.*p;
ey(p+1)=miny+stepy.*p;
ez(p+1)=minz+stepz.*p;
end
yrow=ey;
zrow=ez;
vectcomp=[];
for q=0:pts
yrow(q+1,:)=ey(q+1);
zrow(q+1,:)=ez(q+1);
vect=[ex;yrow(q+1,:)];
vectcomp=[vectcomp,vect];
end
zrow=vectcomp(1,:);
for q=0:pts
zrow(q+1,:)=ez(q+1);
end
vectcomp2=[];
for q=0:pts
vect2=[vectcomp(1,:);vectcomp(2,:);zrow(q+1,:)];
vectcomp2=[vectcomp2,vect2];
end
%End of computational array generation
x0=vectcomp2(1,:);
y0=vectcomp2(2,:);
z0=zplane;
I=input('I=? ');
mu=4*pi*10^(-7);
AllBi=[];
AllBj=[];
AllBk=[];
%The next block of code computes the magnetic field contribution of each
%segment of wire defined by the input vectors at line 3. This computation
%is carried out for each point in the array of computation.
for q1=1:numel(zrow)-1
l=length(x)-1;
for n=1:l
sx(n)=x(n)-x(n+1);
sy(n)=y(n)-y(n+1);
sz(n)=z(n)-z(n+1);
rx(n)=x(n)-x0(q1);
ry(n)=y(n)-y0(q1);
rz(n)=z(n)-z0;
end
s_cross_r_i=sy.*rz-ry.*sz;
s_cross_r_j=-(sx.*rz-rx.*sz);
s_cross_r_k=sx.*ry-rx.*sy;
mag_r_squared=rx.^2+ry.^2+rz.^2;
scri_divrsq=s_cross_r_i./mag_r_squared;
scrj_divrsq=s_cross_r_j./mag_r_squared;
scrk_divrsq=s_cross_r_k./mag_r_squared;
i_all=transpose(scri_divrsq);
j_all=transpose(scrj_divrsq);
k_all=transpose(scrk_divrsq);
i=sum(i_all);
j=sum(j_all);
k=sum(k_all);
Bi=mu.*I./4./pi.*i;
Bj=mu.*I./4./pi.*j;
Bk=mu.*I./4./pi.*k;
AllBi=[AllBi,Bi];
AllBj=[AllBj,Bj];
AllBk=[AllBk,Bk];
end
%End of Biot-Savart Computations
magB=sqrt(AllBi.^2+AllBj.^2+AllBk.^2);
en=0;
st=0;
magBT=[];
%The next block of code generates matricies for plotting each of the
%magnetic field components with the mesh function.
for g=0:pts
st=g*(pts+1)+1;
en=en+pts+1;
magBT=[magBT;magB(st:en)];
end
en=0;
st=0;
magBi=[];
for g=0:pts
st=g*(pts+1)+1;
en=en+pts+1;
magBi=[magBi;AllBi(st:en)];
end
en=0;
st=0;
magBj=[];
for g=0:pts
st=g*(pts+1)+1;
en=en+pts+1;
magBj=[magBj;AllBj(st:en)];
end
en=0;
st=0;
magBk=[];
for g=0:pts
st=g*(pts+1)+1;
en=en+pts+1;
st=g*(pts+1)+1;
en=en+pts+1;
magBk=[magBk;AllBk(st:en)];
end
%Shrink size of z so coils can be super-imposed onto graphs
zshrink=z.*(10^(-4)).*2;
%Generate Summary plot Window with Magnitude, and 3 components of field
subplot(2,2,1); meshc(ex,ey,magBT); title('Magnitude of B')
hold on
plot3(x,y,zshrink,'-g', 'linewidth', 2)
hold off
subplot(2,2,2); meshc(ex,ey,magBi); title('Bi')
hold on
plot3(x,y,zshrink,'-g', 'linewidth', 2)
hold off
subplot(2,2,3); meshc(ex,ey,magBj); title('Bj')
hold on
plot3(x,y,zshrink,'-g', 'linewidth', 2)
hold off
subplot(2,2,4); meshc(ex,ey,magBk); title('Bk')
hold on
plot3(x,y,zshrink,'-g', 'linewidth', 2)
hold off
%Generate individual plot windows of those created above for easier
%viewing.
figure
mesh(ex,ey,magBT); title('Magnitude of B')
hold on
plot3(x,y,zshrink,'-g', 'linewidth', 2)
hold off
figure
mesh(ex,ey,magBi); title('Bi')
hold on
plot3(x,y,zshrink,'-g', 'linewidth', 2)
hold off
figure
mesh(ex,ey,magBj); title('Bj')
hold on
plot3(x,y,zshrink,'-g', 'linewidth', 2)
hold off
figure
mesh(ex,ey,magBk); title('Bk')
hold on
plot3(x,y,zshrink,'-g', 'linewidth', 2)
hold off
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!