How to speed up this script
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hey,
I am reading data from a text file using the following script:
tic
for i = 1:2:length(Data);
Data2(i).H0_SoundSpeed = typecast(uint32(hex2dec(cell2mat(Data{i,1}(1,65:68)))),'single');
Data2(i).H0_Points = hex2dec(cell2mat(Data{i,1}(1,135:136)));
Data2(i).R0_SectionName = convertCharsToStrings(char(hex2dec(Data{i,1}(1,137:138))));
Data2(i).R0_ScalingFactor = typecast(uint32(hex2dec(cell2mat(Data{i,1}(1,141:144)))),'single');
Data2(i).A2_SectionName = convertCharsToStrings(char(hex2dec(Data{i,1}(1,657:658))));
Data2(i).A2_AngleFirst = typecast(uint32(hex2dec(cell2mat(Data{i,1}(1,661:664)))),'single');
Data2(i).A2_ScalingFactor = typecast(uint32(hex2dec(cell2mat(Data{i,1}(1,665:668)))),'single');
Data2(i).I1_ScalingFactor = typecast(uint32(hex2dec(cell2mat(Data{i,1}(1,1209:1212)))),'single');
Data2(i).A2_AngleStep(1) = 0 ;
for j = 1 : Data2(i).H0_Points ;
factor = Data2(i).H0_SoundSpeed * Data2(i).R0_ScalingFactor / 2 ;
Data2(i).R0_Range(j) = factor * hex2dec(cell2mat(Data{i,1}(1, (2*j+143):(2*j+144))));
Data2(i).A2_AngleStepTemp(j) = hex2dec(cell2mat(Data{i,1}(1, (2*j+691):(2*j+692))));
Data2(i).A2_AngleStep(j) = Data2(i).A2_AngleFirst + (sum(Data2(i).A2_AngleStepTemp(1:(j)))*Data2(i).A2_ScalingFactor);
Data2(i).I1_Intensity(j) = Data2(i).I1_ScalingFactor * hex2dec(cell2mat(Data{i,1}(1, (2*j+1211):(2*j+1212))));
end
end
Data2 = rmfield(Data2, 'A2_AngleStepTemp' );
toc
It is not the most efficient way of reading it in but it works, however it is a bit slow.
I was wondering if anybody has some tips on how I can speed it up.
Thanks!
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Whos dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!