My data files are labelled WAVE001.CSV, WAVE002.csv..etc.The problem with my code is I can only read it when the files are in right order.If I want to read the code from WAVE0021.csv to WAVE0031.csv how should I modify the code? Please help.

1 view (last 30 days)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%Script for calculating beam divergence%%%%%%%%%%%%%%%%
clc;
clear all;
close all;
%Specifying the folder where all files are located%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A=3.14; %Area in cm2 of one FC
calF = 1000/(A*100); % calibration for mA/cm2
HV=[0.6,0.8,1.0,1.2,1.4,1.6,1.8,2.0];
Datafiles=dir('WAVE00*.csv');
%%%%%%%%%%%%%%%%%%%%Opening the files sequentially%%%%%%%%%%%%%%%%%%%%%%%%%
for file=Datafiles'
fprintf(1,'Reading file %s\n',file.name);
end
%%%%%%%%%%%%%%%%%%%%%Putting the files in order%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:length(Datafiles)
a{i}=csvread(Datafiles(i).name,11,0);
end
%%%%%%%%%%%%%%%%%%%Calculating the average intensity%%%%%%%%%%%%%%%%%%%%%%%
[b]=zeros(8,11);
for j=1:8
[b(j,:)]=mean(a{1,j}(66:76,2:12)*calF);
%%%%%%%%%%Plotting the beam profile along with the gaussian fit%%%%%%%%%%%
A1=[-120,-96,-72,-48,-24,0,24,48,72,96,120];%Radial Distance%
subplot(4,4,j),plot(A1,b(j,:),'o','LineWidth',2,'MarkerSize',8);
hold on
grid on
end
K=zeros(8,3);
for m=1:8
subplot(4,4,m),R1=fit(A1',b(m,:)','gauss1');
plot(R1,'.k')
set (gca,'fontsize',10, 'fontweight', 'b')
xlabel('Radial distance(mm)');
ylabel('J(mA/cm^{2})');
legend('Data','fit');
axis([-200 200 0 0.09]);
hold on
%Calculating the Coefficients%
K(m,:)=coeffvalues(R1);
title(['HV:',num2str(HV(m)),'kV'])
end
%%%%%%%%%%Calculating the beam diameter from 1/e width ie the SD%%%%%%%%%%
[B]=zeros(8,1);
for l=1:8
B(l)=2.35*K(l,3);
end
%%%%%%%%%%%%%%%Calculating the beam divergence%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Distance_FC=input('Enter the Distance of FC in mm: ');
[D]=zeros(8,1);
for jj=1:8
D(jj)=(180/3.14)*atan((B(jj)-55)/(Distance_FC*2));
end
%%%%%%%%%%%%%%%%%Plotting Beam Dia%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HV=[0.6,0.8,1.0,1.2,1.4,1.6,1.8,2.0];
figure(22)
plot(HV,B,'o','LineWidth',2,'MarkerSize',8);
hold on
grid on
set (gca,'fontsize',10, 'fontweight', 'b')
xlabel('HV(kV)');
ylabel('Beam diameter(mm)');
title('Beam diameter vs HV');
axis([0 2.5 0 300]);
%%%%%%%%%%%%%%%Plotting Divergence vs HV%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure(33)
plot(HV,D,'o','LineWidth',2,'MarkerSize',8);
hold on
grid on
set (gca,'fontsize',10, 'fontweight', 'b')
xlabel('HV(kV))');
ylabel('Beam divergence(Degree)');
title('Beam Divergence vs HV');
axis([0 2.5 0 14]);

Answers (0)

Products


Release

R2013b

Community Treasure Hunt

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

Start Hunting!