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 (최근 30일)
이전 댓글 표시
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%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]);
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Axis Labels에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!