Electromotive Force Voltage Example
3 views (last 30 days)
Show older comments
Kutlu Yigitturk
on 18 Jun 2021
Answered: Mouhamed Niasse
on 18 Jun 2021
B = [0 0 1]'; v = [0 1 0]'; length = [1 1 1]'; length = length/norm(length);
eVec = cross(v,B); eMag = dot(eVec,length); az = 50; el = 15;
close all;
grn = [0 .8 0]; brn = [.8 .5 0];
Fig = figure; Fig.Position = Fig.Position + [-200 0 100 0];
subplot(1,2,1)
plot3([0 B(1)],[0 B(2)],[0 B(3)],'b','linewidth',3); hold on, grid on
plot3([0 v(1)],[0 v(2)],[0 v(3)],'color',grn,'linewidth',3);
plot3([0 eVec(1)],[0 eVec(2)],[0 eVec(3)],'r','linewidth',3);
text(B(1),B(2),B(3)*1.2,'B','color','b')
text(v(1),v(2)*1.2,v(3),'v','color',grn)
text(eVec(1)*1.0,eVec(2)-.2,eVec(3)+.2,'eVec','color','r')
text(-1.2,-1.5,-1,num2str(B),'color','b'), text(-1.2,-1.5,-.2,'B','color','b'),
text(-.5,-1.5,-1,num2str(v),'color',grn), text(-.5,-1.5,-.2,'v','color','b'),
text(0.2,-1.5,-1,num2str(eVec),'color','r'),text(0.2,-1.7,-.2,'eVec','color','r'),
text(0.9,-1.5,-1,num2str(length,4),'color',brn), text(0.9,-1.6,-.3,'Rod','color',brn)
title('eVec = cross(v,B) eMag = dot(eVec,length)')
set(gca,'color',[1 1 1]*.9)
axis('equal'), axis([-1 1 -1 1 -1 1]*1.5), view(az,el)
Rod0 = [-length length]*0.75; Rod = Rod0 + v*0;
plot3(Rod(1,:),Rod(2,:),Rod(3,:),'linewidth',6,'color',brn);
text(Rod(1,1),Rod(2,1),Rod(3,1)+.3,'Rod','color',brn)
text(Rod(1,2)-.4,Rod(2,2),Rod(3,2)-.3,['eMag = ',num2str(eMag)],'color',brn)
xlabel('x'), ylabel('y'), zlabel('z')
subplot(1,2,2)
plot3([0 B(1)],[0 B(2)],[0 B(3)],'b','linewidth',1); hold on, grid on
plot3([0 v(1)],[0 v(2)],[0 v(3)],'g','linewidth',1);
plot3([0 eVec(1)],[0 eVec(2)],[0 eVec(3)],'r','linewidth',1);
set(gca,'color',[1 1 1]*.9)
axis('equal'), axis([-1 1 -1 1 -1 1]*2),view(az,el)
xlabel('x'), ylabel('y'), zlabel('z')
BFldx = [0 0 -.02 .02 0 0 0 0]; BFldy = [0 0 0 0 0 -.02 .02 0]; BFldz = [-1 1 0.9 0.9 1 .9 .9 1]*1.5;
for i = -2:0.5:2
for j = -2:0.5:2
plot3(BFldx'+i,BFldy'+j,BFldz','linewidth',0.1,'color',[.5 .5 1]);
end
end
drawnow
DrawRod = plot3(Rod(1,:),Rod(2,:),Rod(3,:),'linewidth',6,'color',brn);
TexteMag = text(Rod(1,2)+.1,Rod(2,2)+.1,Rod(3,2)+.1,['+',num2str(eMag)],'color',brn);
Tit = title(['eVec^t = [',num2str([0 0 0]),'] eMag = ',num2str(0)]);
for n = 1:3
Rod = Rod0;
set(DrawRod,'xdata',Rod(1,:),'ydata',Rod(2,:),'zdata',Rod(3,:));
set(TexteMag,'pos',Rod(:,2)+.1,'string',num2str(0))
set(Tit,'string',['eVec^t = [',num2str([0 0 0]),'] eMag = ',num2str(0)]), pause(1)
for m = 0:0.02:1
eVec = cross(v,B); eMag = dot(eVec,length);
Rod = Rod0 + v*m;
set(DrawRod,'xdata',Rod(1,:),'ydata',Rod(2,:),'zdata',Rod(3,:));
set(TexteMag,'pos',Rod(:,2)+.1,'string',num2str(eMag))
set(Tit,'string',['eVec^t = [',num2str(eVec'),'] eMag = ',num2str(eMag)])
drawnow, pause(0.001)
end
end
OUTPUT:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/657980/image.jpeg)
What exactly do eVec and e in this code? Thanks for your help.
0 Comments
Accepted Answer
Mouhamed Niasse
on 18 Jun 2021
Hello,
From the second line of your code, you need to know first what is the physical meaning of each paramaters ('v', 'B', 'length', etc).
eVec = cross(v,B); eMag = dot(eVec,length);
Then you go into MATLAB documentation and read the description of the used functions 'cross' and 'dot'.
Repeat the same process for the rest of the code and you will soon become an expert.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!