# HALL SENSOR MATLAB CODE %Hall Sensor 1 t11=0:0.01:1; t12=1:0.01:2; t13=2:0.01:3; t14=3:0.01:4; t15=4:0.01:5; t16=5:0.01:6; t=[t11 t12 t13 t14 t15 t16]; x11=zeros(size(t11)); x12=zeros(size(t12)); x13=zeros(size(t13)); x14=ones(size(t14)); x15=ones(size(t15)); x16=ones(size(t16)); x=[x11 x12 x13 x14 x15 x16]; subplot(6,1,1); plot(t,x,'r', 'Linewidth',1); axis([0 6 0 1]); xlabel('Time') ylabel('Voltage') title('Hall Sensor 1'); %Hall Sensor 2 t21=0:0.01:1; t22=1:0.01:2; t23=2:0.01:3; t24=3:0.01:4; t25=4:0.01:5; t26=5:0.01:6; t=[t21 t22 t23 t24 t25 t26]; x21=zeros(size(t11)); x22=ones(size(t12)); x23=ones(size(t13)); x24=zeros(size(t14)); x25=zeros(size(t15)); x26=ones(size(t16)); x=[x21 x22 x23 x24 x25 x26]; subplot(6,1,2); plot(t,x,'r', 'Linewidth',1); axis([0 6 0 1]); subplot(6,1,2); xlabel('Time') ylabel('Voltage') title('Hall Sensor 2'); %Hall Sensor 3 t31=0:0.01:1; t32=1:0.01:2; t33=2:0.01:3; t34=3:0.01:4; t35=4:0.01:5; t36=5:0.01:6; t=[t31 t32 t33 t34 t35 t36]; x31=ones(size(t31)); x32=zeros(size(t32)); x33=ones(size(t33)); x34=zeros(size(t34)); x35=ones(size(t35)); x36=zeros(size(t36)); x=[x31 x32 x33 x34 x35 x36]; subplot(6,1,3); plot(t,x,'r', 'Linewidth',1); axis([0 6 0 1]); subplot(6,1,3); xlabel('Time') ylabel('Voltage') title('Hall Sensor 3'); %Phase A t41=0:0.01:1; t42=1:0.01:2; t43=2:0.01:3; t44=3:0.01:4; t45=4:0.01:5; t46=5:0.01:6; t=[t41 t42 t43 t44 t45 t46]; x41=zeros(size(t41)); x42=-t42; x43=-t43; x44=ones(size(t44)); x45=ones(size(t45)); x46=zeros(size(t46)); x=[x41 x42 x43 x44 x45 x46]; subplot(6,1,4); plot(t,x,'r', 'Linewidth',1); axis([0 6 -4 3]); subplot(6,1,4); xlabel('Time') ylabel('Voltage') title('Phase A'); %Phase B t51=0:0.01:1; t52=1:0.01:2; t53=2:0.01:3; t54=3:0.01:4; t55=4:0.01:5; t56=5:0.01:6; t=[t41 t42 t43 t44 t45 t46]; x51=ones(size(t51)); x52=zeros(size(t52)); x53=ones(size(t53)); x54=-t54; x55=zeros(size(t55)); x56=-t56; x=[x51 x52 x53 x54 x55 x56]; subplot(6,1,5); plot(t,x,'r', 'Linewidth',1); axis([0 6 -6 3]); subplot(6,1,5); xlabel('Time') ylabel('Voltage') title('Phase B'); %Phase C t61=0:0.01:1; t62=1:0.01:2; t63=2:0.01:3; t64=3:0.01:4; t65=4:0.01:5; t66=5:0.01:6; t=[t61 t62 t63 t64 t65 t66]; x61=-t61; x62=ones(size(t62)); x63=zeros(size(t63)); x64=zeros(size(t64)); x65=-t65; x66=ones(size(t66)); x=[x61 x62 x63 x64 x65 x66]; subplot(6,1,6); plot(t,x,'r', 'Linewidth',1); axis([0 6 -8 3]); subplot(6,1,6); xlabel('Time') ylabel('Voltage') title('Phase C'); ![](https://i.imgur.com/05kjoXz.png)