Select best time in an array
古いコメントを表示
Hi everyone! So i have this function that creates a .tx with drivers and their respective lap times:
function txtcreator_v2(drivers_scuderias,file)
%TXTCREATOR asigna un tiempo de vuelta a cada conductor y escribe los
%resultados en un archivo .txt.
%driversscuderias debe ser un string array
%file es el nombre del archivo que queremos crear
minutes = randi(2,1,100); seconds = randi(59,1,100); milliseconds=randi(999,1,100);
%generador de tiempo
fid = fopen(file,'w+');
for i=1:length(minutes)
fangio = randi(20,1,1);
fprintf(fid,'%s;%s;%d:%02d.%03d\n',drivers_scuderias(fangio,1),drivers_scuderias(fangio,2),minutes(i),seconds(i),milliseconds(i));
end
fclose(fid);
end
and then a script that reads the text file and structures it:
driv_scu= ["LEC" "SAI" "BOT" "ZHO" "ALB" "LAT" "VER" "PER" "HAM" ...
"RUS" "NOR" "RIC" "MSC" "MAG" "STR" "VET" "GAS" "TSU" "ALO" "OCO";"ferrari" "ferrari" "alfa romeo" "alfa romeo" "williams" "williams" "red bull" "red bull" "mercedes" "mercedes"...
"mclaren" "mclaren" "haas" "haas" "aston martin" "aston martin" "alpha tauri" "alpha tauri" "alpine" "alpine"]';
txtcreator_v2(driv_scu,'laptimes.txt')
fid = fopen("laptimes.txt");
parrilla = textscan(fid,'%s %s %s','delimiter',';');
fclose(fid);
domenicalli=vertcat( parrilla{1} );
senna=vertcat( parrilla{2} );
prost=vertcat( parrilla{3} );
ayrton= [domenicalli senna prost];
The thing is, i want ayrton to only have the best lap times of each pilot. I mean deleting the repeated names based on their lap times (if hamilton is repited two times, i only keep the "hamilton" with the best lap)
Any clues?
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Other Formats についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!