1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| path = 'C:\Users\Desktop\Praktikum\Aufgaben\Stef S\1-\Matlab\Test1.xlsx'; %Path to the Excel
[~,~,test] = xlsread(path); %Open and read the Excel with Matlab
vehicules = test(2:end,3); %initialisation of the variables
nomsVehicules = unique(vehicules);
for i = 1:length(nomsVehicules)
g = @(x) strcmp(nomsVehicules{i},x);
idx_vehicules{i,1} = find(cellfun(g,vehicules)); %Indexing of the Vehicles per V-Number (idx_vehicules{1,1}: 1st Car; idx_vehicules{2,1}: 2nd Car)
end
compar_A = @(x) strcmp('A',x);
compar_B = @(x) strcmp('B',x);
for i = 1:length(idx_vehicules)
idx_prob_A{i,1} = find(compar_A(test(idx_vehicules{i,1},7))); %Indexing problem A for each Vehicle
idx_prob_B{i,1} = find(compar_B(test(idx_vehicules{i,1},7))); %Indexing problem B for each Vehicle
end
for i = 1:length(idx_vehicules)
kilometrages{i,1} = unique(cat(1,test{idx_vehicules{i}(idx_prob_A{i,1}),10})); % Deleating the Exact sames Lines to make the Excel "lighter" and easier to use
kilometrages{i,1} = kilometrages{i,1}(~isnan(kilometrages{i,1}))
end
c=1;
for i = 1:length(idx_vehicules)
if ~isempty(find(kilometrages{i,1} == cat(1,test{idx_vehicules{i}(idx_prob_B{i,1}),10}))) %A and B at the same km for each Vehicle
informations{c,1} = test{idx_vehicules{i,1}(1),3};
c=c+1;
end
end |
Partager