
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Test für das Öffnen von Dateifile

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


clear all
clc

% a, b, c, d, e, f, g, h, I, j, k, l sind die Nammen der Textdateien.


a = 'travel_angle.txt';
b = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
c = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyy';
d = 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzz';
e = '';
f = '';
g = '';
h = '';
I = ''
j = '';
k = '';
l = '';


K = {a b c d e f g h I j k l};

m = length(K)
TxtInhalt = [];



%% for a.txt
align_torq_F = [];
toe_F = [];

%% for b.txt
toe_zero_F = []; 
toe_45_F = [];
toe_45_negative_F = [];
toe_90_F = [];
toe_90_negative_F = [];
toe_360_F = [];
toe_360_negative_F = [];
%% c

vel_F = [];
force_F = [];

%% for 'd'
lat_Force_F = []; % lateral load front
camber_var_F = []; % camber angle front
%% for e.txt

lat_Force_toe_F = []; % lateral load front
toe_lat_F = [];       % toe front

%%



i = 1;
while i <= m
    

% Öffnen der Datei/open the file
fid = fopen(K{i},'r') 

% Textinhalt ohne Header lesen/ read the text without the header
TxtInhalt = ([TxtInhalt textscan(fid,'%s %s','Headerlines',1)])

fclose(fid)

             switch(K{i})
                 
%%
                 case a
                    disp('ja a')
        
        
                    align_torque = str2double(TxtInhalt{:,i});
                    toe = str2double(TxtInhalt{:,i+1});
    
                    k1 = find(isnan(align_torque));
                    k2 = find(isnan(toe));
                    xxx = length(k2);
                    
                    align_torq_F = ([align_torq_F  align_torque((k2(1)+1):(k2(2)-1))])
                    toe_F = ([toe_F  toe((k2(1)+1):(k2(2)-1))])
     
                        for j = 3: xxx
                                
                                k2(end) = k1(end);
          
                                if((k2(j) - align_torque(k2(j)-1) > 5)) 
              
                                 disp('ja Torque')
                                 align_torq_F = ([align_torq_F  align_torque((k2(j-1)+2):(k2(j)-1))]);
                                 toe_F = ([toe_F  toe((k2(j-1)+2):(k2(j)-1))]);
                               

                                end 
                         end    
%%
            
            
            
                 case b
                
                         disp('ja b')
                         % % find the non-number index
                         
                         kinw_t = str2double(TxtInhalt{:,(i+1)});
                         toe = str2double(TxtInhalt{:,i+2});
                         k1 = find(isnan(kinw_t));
                         k2 = find(isnan(toe));
                         xxx = length(k1);
                        
                         j = 2;
                         while j < xxx
          
                                  if((k1(j) - kinw_t(k1(j)-1) > 5) & kinw_t(k1(j-1)+1)== 45) 

                                    % toe_zero = ([toe_zero xx((k(i)+1):(k(2)-1))])
% 
                                    toe_45_F = ([toe_45_F toe((k1(j-1)+2):(k1(j)-1))]);
                              

                                  end 
                                   
                                  if((k1(j) - kinw_t(k1(j)-1) > 5) & kinw_t(k1(j-1)+1)== -45)
% 
                                    toe_45_negative_F = ([toe_45_negative_F toe((k1(j-1)+2):(k1(j)-1))]);

                                  end
                                  
                                  if((k1(j) - kinw_t(k1(j)-1) > 5) & kinw_t(k1(j-1)+1)== 90); 

                                    toe_90_F = ([toe_90_F toe((k1(j-1)+2):(k1(j)-1))]);

                                  end
                                  
                                 if((k1(j) - kinw_t(k1(j)-1) > 5) & kinw_t(k1(j-1)+1)== -90);
 
                                 toe_90_negative_F = ([toe_90_negative_F toe((k1(j-1)+2):(k1(j)-1))]);
            
                                 end
   
                                 if((k1(j) - kinw_t(k1(j)-1) > 5) & kinw_t(k1(j-1)+1)== 360); 

                                    toe_360_F = ([toe_90_F toe((k1(j-1)+2):(k1(j)-1))]);

                                 end
                                  
                                  if((k1(j) - kinw_t(k1(j)-1) > 5) & kinw_t(k1(j-1)+1)== -360);
% 
                                    toe_360_negative_F = ([toe_90_negative_F toe((k1(j-1)+2):(k1(j)-1))]);

                                  end
                                  
                                    
                                if((k1(j) - kinw_t(k1(j)-1) > 5) & kinw_t(k1(j-1)+1)== 0); 
                                % toe_zero = ([toe_zero xx((k(i)+1):(k(2)-1))])
% 
                                    toe_zero_F = ([toe_zero_F toe((k1(j-1)+2):(k1(j)-1))]);

                                end
                                  
                          
                                 j = j+1;
                        end
                       
Zero_LRW_toe_F = [toe_zero_F(:,1) toe_zero_F(:,2)];
LRW_45_toe_F = [toe_45_F(:,1) toe_45_F(:,2)];
LRW_45_toe_neg_F = [toe_45_negative_F(:,1) toe_45_negative_F(:,2)];
LRW_90_toe_F = [toe_90_F(:,1) toe_90_F(:,2)];
LRW_90_toe_neg_F = [toe_90_negative_F(:,1) toe_90_negative_F(:,2)];
LRW_360_toe_F = [toe_360_F(:,1) toe_360_F(:,2)];
LRW_360_toe_neg_F = [toe_360_negative_F(:,1) toe_360_negative_F(:,2)];

%% camber angle for (0, 360, -360)degrees

LRW_zero_camber_F = [toe_zero_F(:,3)];
LRW_360_camber_F = [toe_360_F(:,3)];
LRW_360_toe_neg_F = [toe_360_negative_F(:,3)];
            
             
         
                 case c
                
                         disp('ja c')  
                         
                         vel_F = ([vel_F str2double(TxtInhalt{:,((i*2)-1)})]);
                         force_F = ([force_F str2double(TxtInhalt{:,i*2})]);
                         
                    case d
                
                         disp('ja d')  
                         
                         lat_Force_F = ([lat_Force_F str2double(TxtInhalt{:,((i*2)-1)})]);
                         camber_var_F = ([camber_var_F str2double(TxtInhalt{:,i*2})]); 
                         
                          lat_Force_F = lat_Force_F(1: length(camber_var_F)); 
                       
                          case e
                            
                              disp('ja e')    
                     
                
                         lat_Force_toe_F = ([lat_Force_toe_F str2double(TxtInhalt{:,((i*2)-1)})]);
                         toe_lat_F = ([toe_lat_F str2double(TxtInhalt{:,i*2})]); 
                         
                          k1 = find(isnan(lat_Force_toe_F));
                          k2 = find(isnan(toe_lat_F));
                          lat_Force_toe_F =  lat_Force_toe_F((k2(1)+1): lat_Force_toe_F(k(1)-1)
%                         toe_lat_F = 
                       
                         
                         
                          
                  
             end
         i = i +1; 
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 




































