Azzera filtri
Azzera filtri

I want to reduce the length of my program.It is very repetitive.Since I am not from a programming background can anyone suggest or help me improve my code for plotting multiple beam profiles?

2 visualizzazioni (ultimi 30 giorni)
clc;
clear all;
close all;
%-------Date:041020119--------Data with new pressure guage and 4 filaments---%
%Set for pressure 1e-4Torr Faraday cup grounded and repellor bias of V:-30V
%Filament current was varied for different shots%
%Area of beam%
%DATA PLOTTED AT 13TH SECOND OF THE SHOT%
A=3.14; %Area in cm2 of one FC
calF = 1000/(A*100); % calbration for mA/cm2 100 is for resistance
calF1=1000000/(A*100);%calibration for microA/cm2
a0 =csvread('WAVE0015.CSV',11,0);%PS current 4mA %
a1 =csvread('WAVE0014.CSV',11,0);%PS current 7mA %
a2 =csvread('WAVE0013.CSV',11,0);%PS current 8mA %
a3 =csvread('WAVE0012.CSV',11,0);%PS current 11mA %
a4 =csvread('WAVE0010.CSV',11,0);%PS current 13mA %
a5=csvread('WAVE0011.CSV',11,0);%PS current 16mA %
a6=csvread('WAVE0008.CSV',11,0);%PS current 18mA %
a7=csvread('WAVE0009.CSV',11,0);%PS current 20mA %
a8 =csvread('WAVE0007.CSV',11,0);%PS current 24mA %
a9 =csvread('WAVE0006.CSV',11,0);%PS current 29mA %
a10 =csvread('WAVE0005.CSV',11,0);%PS current 33mA %
a11 =csvread('WAVE0003.CSV',11,0);%PS current 38mA %
a12 =csvread('WAVE0004.CSV',11,0);%PS current 43mA %
a13=csvread('WAVE0001.CSV',11,0);%PS current 53mA %
%--------------------------------------------------------------------------%
%---------4mA-------------------------------------------------------------%
% figure(7);
A1=[-120,-96,-72,-48,-24,0,24,48,72,96,120];%Axial Distance%
Y51=mean(a0(46:51,2:12))*calF1;%Average from 9-10 1second%
subplot(4,4,1),plot(A1,Y51,'o','LineWidth',2,'MarkerSize',8);
hold on
grid on
% figure(7);
subplot(4,4,1),R1=fit(A1',Y51','gauss1');
plot(R1,'.k');
set (gca,'fontsize',10, 'fontweight', 'b')
xlabel('Radial distance(mm)');
ylabel('Current (microA/cm2)');
title('4mA');
legend('Data','fit');
hold on
K1=coeffvalues(R1);
B0 = sqrt(2)*K1(3);%i/e definition of divergence%
L0=K1(2);
Z1=9.4*K1(1)*K1(3).^2/1000000;%Correction for converting to miliampere%
%---------7mA-------------------------------------------------------------%
% figure(2);
X=[-120,-96,-72,-48,-24,0,24,48,72,96,120];%Axial Distance%
Y=mean(a1(46:51,2:12))*calF1;%Averaged value over 1second%
subplot(4,4,2),plot(X,Y,'o','LineWidth',2,'MarkerSize',8);
hold on
grid on
set (gca,'fontsize',10, 'fontweight', 'b')
% figure(2);
func=fit(X',Y','gauss1');
subplot(4,4,2),plot(func,'.k');
set (gca,'fontsize',10, 'fontweight', 'b')
xlabel('Radial distance(mm)');
ylabel('Current (mA/cm2)');
title('7mA');
legend('data','fit');
M=coeffvalues(func);
B1 = sqrt(2)*M(3)
L1=M(2);
%----------------------------------------------------------------------------------------%
Z2=9.4*M(1)*M(3).^2/1000000;
%---------8mA-------------------------------------------------------------%
% figure(3);
X1=[-120,-96,-72,-48,-24,0,24,48,72,96,120];%Axial Distance%
Y1=mean(a2(81:101,2:12))*calF1;
subplot(4,4,3),plot(X1,Y1,'o','LineWidth',2,'MarkerSize',8);
hold on
grid on
% figure(3);
h=fit(X1',Y1','gauss1');
subplot(4,4,3),plot(h,'.k');
set (gca,'fontsize',10, 'fontweight', 'b')
xlabel('Radial distance(mm)');
ylabel('Current (microA/cm2)');
title('8mA');
legend('Data','fit');
hold on
M1=coeffvalues(h);
B2 = sqrt(2)*M1(3);
L2=M1(2);
%----------------------------------------------------------------------------------------%
Z3=9.4*M1(1)*M1(3).^2/1000000;
%---------11mA-------------------------------------------------------------%
% figure(4);
X2=[-120,-96,-72,-48,-24,0,24,48,72,96,120];%Axial Distance%
Y2=mean(a3(81:101,2:12))*calF;
subplot(4,4,4),plot(X2,Y2,'o','LineWidth',2,'MarkerSize',8);
hold on
grid on
% figure(4);
h1=fit(X2',Y2','gauss1');
subplot(4,4,4),plot(h1,'.k');
set (gca,'fontsize',10, 'fontweight', 'b')
xlabel('Radial distance(mm)');
ylabel('Current (mA/cm2)');
title('11mA');
legend('Data','fit');
axis([-200 200 0 0.02]);
hold on
M2=coeffvalues(h1);
B3 = sqrt(2)*M2(3);
L3=M2(2);
Z4=9.4*M2(1)*M2(3).^2*10E-3;
%---------13mA-------------------------------------------------------------%
% figure(5);
X3=[-120,-96,-72,-48,-24,0,24,48,72,96,120];%Axial Distance%
Y3=mean(a4(81:101,2:12))*calF;
subplot(4,4,5),plot(X3,Y3,'o','LineWidth',2,'MarkerSize',8);
hold on
grid on
% figure(5);
h2=fit(X3',Y3','gauss1');
subplot(4,4,5),plot(h2,'.k');
set (gca,'fontsize',10, 'fontweight', 'b')
xlabel('Radial distance(mm)');
ylabel('Current (mA/cm2)');
title('13mA');
legend('Data','fit');
axis([-200 200 0 0.02]);
hold on
M3=coeffvalues(h2);
B4 = sqrt(2)*M3(3);
L4=M3(2);
Z5=9.4*M3(1)*M3(3).^2*10E-3;
%---------16mA------------------------------------------------------------%
% figure(6);
X4=[-120,-96,-72,-48,-24,0,24,48,72,96,120];%Axial Distance%
Y4=mean(a5(81:101,2:12))*calF;
subplot(4,4,6),plot(X4,Y4,'o','LineWidth',2,'MarkerSize',8);
hold on
grid on
set (gca,'fontsize',10, 'fontweight', 'b')
%
% figure(6);
h3=fit(X4',Y4','gauss1');
subplot(4,4,6),plot(h3,'.k');
xlabel('Radial distance(mm)');
ylabel('Current (mA/cm2)');
title('16mA');
legend('Data','fit');
axis([-200 200 0 0.05]);
hold on
M4=coeffvalues(h3);
B5 = sqrt(2)*M4(3);
L5=M4(2);
Z6=9.4*M4(1)*M4(3).^2*10E-3;
%---------18mA-------------------------------------------------------------%
% figure(6);
X5=[-120,-96,-72,-48,-24,0,24,48,72,96,120];%Axial Distance%
Y5=mean(a6(81:101,2:12))*calF;
subplot(4,4,7),plot(X5,Y5,'o','LineWidth',2,'MarkerSize',8);
hold on
grid on
set (gca,'fontsize',10, 'fontweight', 'b')
% figure(6);
h4=fit(X5',Y5','gauss1');
subplot(4,4,7),plot(h4,'.k');
xlabel('Radial distance(mm)');
ylabel('Current (mA/cm2)');
title('18mA');
legend('Data','fit');
axis([-200 200 0 0.05]);
hold on
M5=coeffvalues(h4);
B6 = sqrt(2)*M5(3);
L6=M5(2);
Z7=9.4*M5(1)*M5(3).^2*10E-3;
%---------20mA-------------------------------------------------------------%
% figure(6);
X6=[-120,-96,-72,-48,-24,0,24,48,72,96,120];%Axial Distance%
Y6=mean(a7(81:101,2:12))*calF;
subplot(4,4,8),plot(X6,Y6,'o','LineWidth',2,'MarkerSize',8);
hold on
grid on
set (gca,'fontsize',10, 'fontweight', 'b')
% figure(6);
L=fit(X6',Y6','gauss1');
subplot(4,4,8),plot(L,'.k');
xlabel('Radial distance(mm)');
ylabel('Current (mA/cm2)');
title('20mA');
legend('Data','fit');
axis([-200 200 0 0.05]);
hold on
M6=coeffvalues(L);
B7 = sqrt(2)*M6(3);
L7=M6(2);
Z8=9.4*M6(1)*M6(3).^2*10E-3;
%---------24mA-------------------------------------------------------------%
% figure(6);
X7=[-120,-96,-72,-48,-24,0,24,48,72,96,120];%Axial Distance%
Y7=mean(a8(81:101,2:12))*calF;
subplot(4,4,9),plot(X7,Y7,'o','LineWidth',2,'MarkerSize',8);
hold on
grid on
set (gca,'fontsize',10, 'fontweight', 'b')
% figure(6);
L11=fit(X7',Y7','gauss1');
subplot(4,4,9),plot(L11,'.k');
xlabel('Radial distance(mm)');
ylabel('Current (mA/cm2)');
title('24mA');
legend('Data','fit');
axis([-200 200 0 0.05]);
hold on
M7=coeffvalues(L11);
B8 = sqrt(2)*M7(3);
L71=M7(2);
Z9=9.4*M7(1)*M7(3).^2*10E-3;
%---------29mA-------------------------------------------------------------%
% figure(6);
X8=[-120,-96,-72,-48,-24,0,24,48,72,96,120];%Axial Distance%
Y8=mean(a9(81:101,2:12))*calF;
subplot(4,4,10),plot(X8,Y8,'o','LineWidth',2,'MarkerSize',8);
hold on
grid on
set (gca,'fontsize',10, 'fontweight', 'b')
% figure(6);
L21=fit(X8',Y8','gauss1');
subplot(4,4,10),plot(L21,'.k');
xlabel('Radial distance(mm)');
ylabel('Current (mA/cm2)');
title('29mA');
legend('Data','fit');
axis([-200 200 0 0.1]);
hold on
M8=coeffvalues(L21);
B9 = sqrt(2)*M8(3);
L8=M8(2);
Z10=9.4*M8(1)*M8(3).^2*10E-3;
%---------33mA-------------------------------------------------------------%
% figure(6);
X9=[-120,-96,-72,-48,-24,0,24,48,72,96,120];%Axial Distance%
Y9=mean(a10(36:41,2:12))*calF;%Averaged value over 7:8 =1 second%
subplot(4,4,11),plot(X9,Y9,'o','LineWidth',2,'MarkerSize',8);
hold on
grid on
set (gca,'fontsize',10, 'fontweight', 'b')
% figure(6);
L31=fit(X9',Y9','gauss1');
subplot(4,4,11),plot(L31,'.k');
xlabel('Radial distance(mm)');
ylabel('Current (mA/cm2)');
title('33mA');
legend('Data','fit');
axis([-200 200 0 0.1]);
hold on
M9=coeffvalues(L31);
B10 = sqrt(2)*M9(3);
L9=M9(2);
Z11=9.4*M9(1)*M9(3).^2*10E-3;
%---------38mA-------------------------------------------------------------%
% figure(6);
X10=[-120,-96,-72,-48,-24,0,24,48,72,96,120];%Axial Distance%
Y10=mean(a11(51:77,2:12))*calF;
subplot(4,4,12),plot(X10,Y10,'o','LineWidth',2,'MarkerSize',8);
hold on
grid on
set (gca,'fontsize',10, 'fontweight', 'b')
% figure(6);
L41=fit(X10',Y10','gauss1');
subplot(4,4,12),plot(L41,'.k');
xlabel('Radial distance(mm)');
ylabel('Current (mA/cm2)');
title('38mA');
legend('Data','fit');
axis([-200 200 0 0.1]);
hold on
M10=coeffvalues(L41);
B11 = sqrt(2)*M10(3);
L10=M10(2);
Z12=9.4*M10(1)*M10(3).^2*10E-3;
%---------43mA-------------------------------------------------------------%
% figure(6);
X11=[-120,-96,-72,-48,-24,0,24,48,72,96,120];%Axial Distance%
Y11=mean(a12(81:101,2:12))*calF;
subplot(4,4,13),plot(X11,Y11,'o','LineWidth',2,'MarkerSize',8);
hold on
grid on
set (gca,'fontsize',10, 'fontweight', 'b')
% figure(6);
L51=fit(X11',Y11','gauss1');
subplot(4,4,13),plot(L51,'.k');
xlabel('Radial distance(mm)');
ylabel('Current (mA/cm2)');
title('43mA');
legend('Data','fit');
axis([-200 200 0 0.1]);
hold on
M11=coeffvalues(L51);
B12 = sqrt(2)*M11(3);
L11=M11(2);
Z13=9.4*M11(1)*M11(3).^2*10E-3;
%---------53mA-------------------------------------------------------------%
% figure(6);
X12=[-120,-96,-72,-48,-24,0,24,48,72,96,120];%Axial Distance%
Y12=mean(a13(51:77,2:12))*calF;%Changed the averaging interval due to noise between 15-20s%
subplot(4,4,14),plot(X12,Y12,'o','LineWidth',2,'MarkerSize',8);
hold on
grid on
set (gca,'fontsize',10, 'fontweight', 'b')
% figure(6);
L61=fit(X12',Y12','gauss1');
subplot(4,4,14),plot(L61,'.k');
xlabel('Radial distance(mm)');
ylabel('Current (mA/cm2)');
title('53mA');
legend('Data','fit');
axis([-200 200 0 0.1]);
hold on
M12=coeffvalues(L61);
B13 = sqrt(2)*M12(3);
L12=M12(2);
Z14=9.4*M12(1)*M12(3).^2*10E-3;
%-------------------Beam Radius(mm)--------------------------------------------------------------------%
figure(7);
I_int=[Z1,Z2,Z3,Z4,Z5,Z6,Z7,Z8,Z9,Z10,Z11,Z12,Z13,Z14];%INTEGRATED CURRENT%
Ips=[4,7,8,11,13,16,18,20,24,29,33,38,43,53];%Power supply Current%
Ib=[20,34,44,59,76,94,105,121,141,176,199,220,242,280]/7;%Beam current%
Ig=Ips-Ib;
B=[B0,B1,B2,B3,B4,B5,B6,B7,B8,B9,B10,B11,B12,B13];
plot(Ips,B,'o','LineWidth',2,'MarkerSize',12);
hold on
grid on
set (gca,'fontsize',10, 'fontweight', 'b')
xlabel('Extracted Current(mA)');
ylabel('Beam Radius(mm)');
title('Beam Radius vs Extracted Current');
axis([0 55 0 200]);
%----------------Beam divergence----------------------------------------------------------------------------------------------%
figure(8);
d0=(180/3.14)*atan((B0-55)/(628));
d1=(180/3.14)*atan((B1-55)/(628));
d2=(180/3.14)*atan((B2-55)/(628));
d3=(180/3.14)*atan((B3-55)/(628));
d4=(180/3.14)*atan((B4-55)/(628));
d5=(180/3.14)*atan((B5-55)/(628));
d6=(180/3.14)*atan((B6-55)/(628));
d7=(180/3.14)*atan((B7-55)/(628));
d8=(180/3.14)*atan((B8-55)/(628));
d9=(180/3.14)*atan((B9-55)/(628));
d10=(180/3.14)*atan((B10-55)/(628));
d11=(180/3.14)*atan((B11-55)/(628));
d12=(180/3.14)*atan((B12-55)/(628));
d13=(180/3.14)*atan((B13-55)/(628));
Divergence=[d0,d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13];
plot(Ips,Divergence,'o','LineWidth',2,'MarkerSize',8);
hold on
grid on
set (gca,'fontsize',10, 'fontweight', 'b')
xlabel('Extracted Current(mA))');
ylabel('Beam divergence(Degree)');
title('Beam Divergence vs Extracted');
axis([0 55 0 10]);
figure(9)
plot(Ig,Divergence,'s','LineWidth',2,'MarkerSize',12);
hold on
grid on
set (gca,'fontsize',10, 'fontweight', 'b')
xlabel('Grid Current(mA)');
ylabel('Beam Divergence(Degree');
title('Beam Divergence vs Grid Current');
axis([0 15 0 10]);
%--------------------------------------------
l=a10(:,1);%time in seconds%
C1=a10(:,2)*calF;
C2=a10(:,3)*calF;
C3=a10(:,4)*calF;
C4=a10(:,5)*calF;
C5=a10(:,6)*calF;
C6=a10(:,7)*calF;
C7=a10(:,8)*calF;
C8=a10(:,9)*calF;
C9=a10(:,10)*calF;
C10=a10(:,11)*calF;
C11=a10(:,12)*calF;
figure();
plot(l,C1,'-r','LineWidth',2,'MarkerSize',5);
hold on
plot(l,C2,'.k','LineWidth',2,'MarkerSize',12);
hold on
plot(l,C3,'.g','LineWidth',2,'MarkerSize',12);
hold on
plot(l,C4,'.m','LineWidth',2,'MarkerSize',12);
hold on
plot(l,C5,'sk','LineWidth',2,'MarkerSize',5);
hold on
plot(l,C6,'ob','LineWidth',2,'MarkerSize',5);
hold on
plot(l,C7,'--c','LineWidth',2,'MarkerSize',5);
hold on
plot(l,C8,'--r','LineWidth',2,'MarkerSize',5);
hold on
plot(l,C9,'ok','LineWidth',2,'MarkerSize',5);
hold on
plot(l,C10,'--xr','LineWidth',2,'MarkerSize',5);
hold on
plot(l,C11,'b','LineWidth',2,'MarkerSize',5);
hold on
grid on
set (gca,'fontsize',16, 'fontweight', 'b')
xlabel('Shot duration (s)');
ylabel('Current density (mA/cm2)');
title('Current in different channel');
legend('c1','C2','C3','C4','C5','C6','C7','C8','C9','C10','C11');
hold on
figure()
plot(Ips,Divergence,'or','LineWidth',2,'MarkerSize',8);
hold on
grid on
set (gca,'fontsize',10, 'fontweight', 'b')
xlabel(' Extracted Current(mA))');
ylabel('Beam divergence(Degree)');
title('Beam Divergence ');
axis([0 60 0 10])
figure()
plot(I_int,Divergence,'xk','LineWidth',2,'MarkerSize',8);
grid on
hold on
set (gca,'fontsize',10, 'fontweight', 'b')
xlabel(' Beam Current(mA))');
ylabel('Beam divergence(Degree)');
title('Beam Divergence ');
axis([0 60 0 10])
figure()
plot(Ig,Divergence,'>','LineWidth',2,'MarkerSize',8);
grid on
hold on
set (gca,'fontsize',10, 'fontweight', 'b')
xlabel(' Grid Current(mA))');
ylabel('Beam divergence(Degree)');
title('Beam Divergence ');
%_____________________________________________________________________________
figure()
MM1=100*Ips/1000^1.5;
MM2=Ig./Ips;
MM3=Ig./Ib;
MM4=100*Ib/1000^1.5;
plot(100*Ips/1000^1.5,Ig./Ips,'or','LineWidth',2,'MarkerSize',8);
hold on
grid on
MM=fit(MM1',MM2','poly2');
plot(MM,'.r');
plot(100*Ib/1000^1.5,Ig./Ib,'sk','LineWidth',2,'MarkerSize',8);
grid on
LL=fit(MM4',MM3','poly2');
plot(LL,'.k');
hold on
set (gca,'fontsize',10, 'fontweight', 'b')
xlabel(' Perveance');
ylabel('Percentage grid current ratio');
title('Perveance ');
legend('Extracted current','Fit ext','Beam Current','Fit b');
%--------------------------------------------------------------------------------------------------------------------------
figure()
plot(Ib,I_int,'or','LineWidth',2,'MarkerSize',8);
hold on
plot(Ips,I_int,'sk','LineWidth',2,'MarkerSize',8);
hold on
x = linspace(0,60);
y = linspace(0,60);
plot(x,y);
grid on
set (gca,'fontsize',10, 'fontweight', 'b')
xlabel(' Current(mA)');
ylabel(' Integrated Current(mA)');
legend('Beam current','Extracted current')

Risposta accettata

KALYAN ACHARJYA
KALYAN ACHARJYA il 28 Dic 2019
Modificato: KALYAN ACHARJYA il 28 Dic 2019
a0 =csvread('WAVE0015.CSV',11,0);%PS current 4mA %
a1 =csvread('WAVE0014.CSV',11,0);%PS current 7mA %
a2 =csvread('WAVE0013.CSV',11,0);%PS current 8mA %
a3 =csvread('WAVE0012.CSV',11,0);%PS current 11mA %
a4 =csvread('WAVE0010.CSV',11,0);%PS current 13mA %
a5=csvread('WAVE0011.CSV',11,0);%PS current 16mA %
a6=csvread('WAVE0008.CSV',11,0);%PS current 18mA %
a7=csvread('WAVE0009.CSV',11,0);%PS current 20mA %
a8 =csvread('WAVE0007.CSV',11,0);%PS current 24mA %
a9 =csvread('WAVE0006.CSV',11,0);%PS current 29mA %
a10 =csvread('WAVE0005.CSV',11,0);%PS current 33mA %
a11 =csvread('WAVE0003.CSV',11,0);%PS current 38mA %
a12 =csvread('WAVE0004.CSV',11,0);%PS current 43mA %
a13=csvread('WAVE0001.CSV',11,0);%PS current 53mA %
One Better Way:
  1. Read all these files and save in a cell array (Use a cell array or array is better way rather than multiple variables names)
  2. Same for do,d1,d2,d3..... and C1,C2,C3........
  3. You can run a loop to call multiple figures with different colors and linwidth for the following plots assignments (See FAQ)
figure();
plot(l,C1,'-r','LineWidth',2,'MarkerSize',5);
hold on
plot(l,C2,'.k','LineWidth',2,'MarkerSize',12);
hold on
plot(l,C3,'.g','LineWidth',2,'MarkerSize',12);
............................
  3 Commenti
KALYAN ACHARJYA
KALYAN ACHARJYA il 28 Dic 2019
Modificato: KALYAN ACHARJYA il 28 Dic 2019
Please see here the multiple images to call (In your case it's CSV files, minor changes required). To save in cell array do use {} and for scalar use [] array, please do read FAQ here
for i=1:length(files)
.....
a{i}=
end

Accedi per commentare.

Più risposte (1)

BHARAT SINGH RAWAT
BHARAT SINGH RAWAT il 28 Dic 2019
clc;
clear all;
close all;
%-------Date:041020119--------Data with new pressure guage and 4 filaments---%
%Set for pressure 1e-4Torr Faraday cup grounded and repellor bias of V:-30V
%Filament current was varied for different shots%
%Area of beam%
%DATA PLOTTED AT 13TH SECOND OF THE SHOT%
A=3.14; %Area in cm2 of one FC
calF = 1000/(A*100); % calbration for mA/cm2 100 is for resistance
calF1=1000000/(A*100);%calibration for microA/cm2
a0 =csvread('WAVE0015.CSV',11,0);%PS current 4mA %
a1 =csvread('WAVE0014.CSV',11,0);%PS current 7mA %
a2 =csvread('WAVE0013.CSV',11,0);%PS current 8mA %
a3 =csvread('WAVE0012.CSV',11,0);%PS current 11mA %
a4 =csvread('WAVE0010.CSV',11,0);%PS current 13mA %
a5=csvread('WAVE0011.CSV',11,0);%PS current 16mA %
a6=csvread('WAVE0008.CSV',11,0);%PS current 18mA %
a7=csvread('WAVE0009.CSV',11,0);%PS current 20mA %
a8 =csvread('WAVE0007.CSV',11,0);%PS current 24mA %
a9 =csvread('WAVE0006.CSV',11,0);%PS current 29mA %
a10 =csvread('WAVE0005.CSV',11,0);%PS current 33mA %
a11 =csvread('WAVE0003.CSV',11,0);%PS current 38mA %
a12 =csvread('WAVE0004.CSV',11,0);%PS current 43mA %
a13=csvread('WAVE0001.CSV',11,0);%PS current 53mA %
%--------------------------------------------------------------------------%
%---------4mA-------------------------------------------------------------%
figure(1);
A=[-120,-96,-72,-48,-24,0,24,48,72,96,120];%Axial Distance%
Y1=mean(a0(46:51,2:12))*calF1;%Average from 9-10 1second%
Y2=mean(a1(46:51,2:12))*calF1;%Averaged value over 1second%
Y3=mean(a2(81:101,2:12))*calF1;
Y4=mean(a3(81:101,2:12))*calF;
Y5=mean(a4(81:101,2:12))*calF;
Y6=mean(a5(81:101,2:12))*calF;
Y7=mean(a6(81:101,2:12))*calF;
Y8=mean(a7(81:101,2:12))*calF;
Y9=mean(a8(81:101,2:12))*calF;
Y10=mean(a9(81:101,2:12))*calF;
Y11=mean(a10(36:41,2:12))*calF;%Averaged value over 7:8 =1 second%
Y12=mean(a11(51:77,2:12))*calF;
Y13=mean(a12(81:101,2:12))*calF;
Y14=mean(a13(51:77,2:12))*calF;%Changed the averaging interval due to noise between 15-20s%
plot(A,Y1,'o',A,2,'or',A,Y3,'og',A,Y4,'ok',A,Y5,'oc',A,Y6,'sb',A,Y7,'sg',A,Y8,'sr',A,Y9,'sk',A,Y10,'sm',A,Y11,'p',A,Y12,'pr',A,Y13,'pb',A,Y14,'pg','LineWidth',1,'MarkerSize',8);
hold on
grid on
figure(1);
R1=fit(A',Y51','gauss1');
R2=fit(A',Y','gauss1');
R3=fit(A',Y1','gauss1');
R4=fit(A',Y2','gauss1');
R5=fit(A',Y3','gauss1');
R6=fit(A',Y4','gauss1');
R7=fit(A',Y5','gauss1');
R8=fit(A',Y6','gauss1');
R9=fit(A',Y7','gauss1');
R10=fit(A',Y8','gauss1');
R11=fit(A',Y9','gauss1');
R12=fit(A',Y10','gauss1');
R13=fit(A',Y11','gauss1');
R14=fit(A',Y12','gauss1');
figure(1)
plot(R1,'.k');
plot(R2,'.k');
plot(R3,'.k');
plot(R4,'.k');
plot(R5,'.k');
plot(R6,'.k');
plot(R7,'.k');
plot(R8,'.k');
plot(R9,'.k');
plot(R10,'.k');
plot(R11,'.k');
plot(R12,'.k');
plot(R13,'.k');
plot(R14,'.k');
K1=coeffvalues(R1);
K2=coeffvalues(R2);
K3=coeffvalues(R3);
K4=coeffvalues(R4);
K5=coeffvalues(R5);
K6=coeffvalues(R6);
K7=coeffvalues(R7);
K8=coeffvalues(R8);
K9=coeffvalues(R9);
K10=coeffvalues(R10);
K11=coeffvalues(R11);
K12=coeffvalues(R12);
K13=coeffvalues(R13);
K14=coeffvalues(R14);
B0 = sqrt(2)*K1(3);%i/e definition of divergence%
B1 = sqrt(2)*K2(3);
B2 = sqrt(2)*K3(3);
B3 = sqrt(2)*K4(3);
B4 = sqrt(2)*K5(3);
B5 = sqrt(2)*K6(3);
B6 = sqrt(2)*K7(3);
B7 = sqrt(2)*K8(3);
B8 = sqrt(2)*K9(3);
B9 = sqrt(2)*K10(3);
B10 = sqrt(2)*K11(3);
B11 = sqrt(2)*K12(3);
B12 = sqrt(2)*K13(3);
B13 = sqrt(2)*K14(3);
Z1=9.4*K1(1)*K1(3).^2/1000000;%Correction for converting to miliampere%
Z2=9.4*K2(1)*K2(3).^2/1000000;
Z3=9.4*K3(1)*K3(3).^2/1000000;
Z4=9.4*K4(1)*K4(3).^2*10E-3;
Z5=9.4*K5(1)*K5(3).^2*10E-3;
Z6=9.4*K6(1)*K6(3).^2*10E-3;
Z7=9.4*K7(1)*K7(3).^2*10E-3;
Z8=9.4*K8(1)*K8(3).^2*10E-3;
Z9=9.4*K9(1)*K9(3).^2*10E-3;
Z10=9.4*K10(1)*K10(3).^2*10E-3;
Z11=9.4*K11(1)*K11(3).^2*10E-3;
Z12=9.4*K12(1)*K12(3).^2*10E-3;
Z13=9.4*K13(1)*K13(3).^2*10E-3;
Z14=9.4*K14(1)*K14(3).^2*10E-3;
set (gca,'fontsize',10, 'fontweight', 'b')
xlabel('Radial distance(mm)');
ylabel('J (\muA/cm^2)');
hold on
grid on
%-------------------Beam Radius(mm)--------------------------------------------------------------------%
figure(7);
I_int=[Z1,Z2,Z3,Z4,Z5,Z6,Z7,Z8,Z9,Z10,Z11,Z12,Z13,Z14];%INTEGRATED CURRENT%
Ips=[4,7,8,11,13,16,18,20,24,29,33,38,43,53];%Power supply Current%
Ib=[20,34,44,59,76,94,105,121,141,176,199,220,242,280]/7;%Beam current%
Ig=Ips-Ib;
B=[B0,B1,B2,B3,B4,B5,B6,B7,B8,B9,B10,B11,B12,B13];
plot(Ips,B,'o','LineWidth',2,'MarkerSize',12);
hold on
grid on
set (gca,'fontsize',10, 'fontweight', 'b')
xlabel('Extracted Current(mA)');
ylabel('Beam Radius(mm)');
title('Beam Radius vs Extracted Current');
axis([0 55 0 200]);
%----------------Beam divergence----------------------------------------------------------------------------------------------%
figure(8);
d0=(180/3.14)*atan((B0-55)/(628));
d1=(180/3.14)*atan((B1-55)/(628));
d2=(180/3.14)*atan((B2-55)/(628));
d3=(180/3.14)*atan((B3-55)/(628));
d4=(180/3.14)*atan((B4-55)/(628));
d5=(180/3.14)*atan((B5-55)/(628));
d6=(180/3.14)*atan((B6-55)/(628));
d7=(180/3.14)*atan((B7-55)/(628));
d8=(180/3.14)*atan((B8-55)/(628));
d9=(180/3.14)*atan((B9-55)/(628));
d10=(180/3.14)*atan((B10-55)/(628));
d11=(180/3.14)*atan((B11-55)/(628));
d12=(180/3.14)*atan((B12-55)/(628));
d13=(180/3.14)*atan((B13-55)/(628));
Divergence=[d0,d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13];
plot(Ips,Divergence,'o','LineWidth',2,'MarkerSize',8);
hold on
grid on
set (gca,'fontsize',10, 'fontweight', 'b')
xlabel('Extracted Current(mA))');
ylabel('Beam divergence(Degree)');
title('Beam Divergence vs Extracted');
axis([0 55 0 10]);
figure(9)
plot(Ig,Divergence,'s','LineWidth',2,'MarkerSize',12);
hold on
grid on
set (gca,'fontsize',10, 'fontweight', 'b')
xlabel('Grid Current(mA)');
ylabel('Beam Divergence(Degree');
title('Beam Divergence vs Grid Current');
axis([0 15 0 10]);
%--------------------------------------------
l=a10(:,1);%time in seconds%
C1=a10(:,2)*calF;
C2=a10(:,3)*calF;
C3=a10(:,4)*calF;
C4=a10(:,5)*calF;
C5=a10(:,6)*calF;
C6=a10(:,7)*calF;
C7=a10(:,8)*calF;
C8=a10(:,9)*calF;
C9=a10(:,10)*calF;
C10=a10(:,11)*calF;
C11=a10(:,12)*calF;
figure();
plot(l,C1,'-r','LineWidth',2,'MarkerSize',5);
hold on
plot(l,C2,'.k','LineWidth',2,'MarkerSize',12);
hold on
plot(l,C3,'.g','LineWidth',2,'MarkerSize',12);
hold on
plot(l,C4,'.m','LineWidth',2,'MarkerSize',12);
hold on
plot(l,C5,'sk','LineWidth',2,'MarkerSize',5);
hold on
plot(l,C6,'ob','LineWidth',2,'MarkerSize',5);
hold on
plot(l,C7,'--c','LineWidth',2,'MarkerSize',5);
hold on
plot(l,C8,'--r','LineWidth',2,'MarkerSize',5);
hold on
plot(l,C9,'ok','LineWidth',2,'MarkerSize',5);
hold on
plot(l,C10,'--xr','LineWidth',2,'MarkerSize',5);
hold on
plot(l,C11,'b','LineWidth',2,'MarkerSize',5);
hold on
grid on
set (gca,'fontsize',16, 'fontweight', 'b')
xlabel('Shot duration (s)');
ylabel('Current density (mA/cm2)');
title('Current in different channel');
legend('c1','C2','C3','C4','C5','C6','C7','C8','C9','C10','C11');
hold on
figure()
plot(Ips,Divergence,'or','LineWidth',2,'MarkerSize',8);
hold on
grid on
set (gca,'fontsize',10, 'fontweight', 'b')
xlabel(' Extracted Current(mA))');
ylabel('Beam divergence(Degree)');
title('Beam Divergence ');
axis([0 60 0 10])
figure()
plot(I_int,Divergence,'xk','LineWidth',2,'MarkerSize',8);
grid on
hold on
set (gca,'fontsize',10, 'fontweight', 'b')
xlabel(' Beam Current(mA))');
ylabel('Beam divergence(Degree)');
title('Beam Divergence ');
axis([0 60 0 10])
figure()
plot(Ig,Divergence,'>','LineWidth',2,'MarkerSize',8);
grid on
hold on
set (gca,'fontsize',10, 'fontweight', 'b')
xlabel(' Grid Current(mA))');
ylabel('Beam divergence(Degree)');
title('Beam Divergence ');
%_____________________________________________________________________________
figure()
MM1=100*Ips/1000^1.5;
MM2=Ig./Ips;
MM3=Ig./Ib;
MM4=100*Ib/1000^1.5;
plot(100*Ips/1000^1.5,Ig./Ips,'or','LineWidth',2,'MarkerSize',8);
hold on
grid on
MM=fit(MM1',MM2','poly2');
plot(MM,'.r');
plot(100*Ib/1000^1.5,Ig./Ib,'sk','LineWidth',2,'MarkerSize',8);
grid on
LL=fit(MM4',MM3','poly2');
plot(LL,'.k');
hold on
set (gca,'fontsize',10, 'fontweight', 'b')
xlabel(' Perveance');
ylabel('Percentage grid current ratio');
title('Perveance ');
legend('Extracted current','Fit ext','Beam Current','Fit b');
%--------------------------------------------------------------------------------------------------------------------------
figure()
plot(Ib,I_int,'or','LineWidth',2,'MarkerSize',8);
hold on
plot(Ips,I_int,'sk','LineWidth',2,'MarkerSize',8);
hold on
x = linspace(0,60);
y = linspace(0,60);
plot(x,y);
grid on
set (gca,'fontsize',10, 'fontweight', 'b')
xlabel(' Current(mA)');
ylabel(' Integrated Current(mA)');
legend('Beam current','Extracted current')

Categorie

Scopri di più su Fractals in Help Center e File Exchange

Prodotti


Release

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by