Read table in .txt to MATLAB
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Karl Zammit
am 17 Apr. 2021
Kommentiert: Karl Zammit
am 19 Apr. 2021
I have the following .txt fil and wish to save the columns seperately for further polar extrapolation. However, the following code is resulting in some funny values.
I appreciate any help. I think I am reading the data wrong as I dont fully understand the concept.
Thanks in advance.
%Read data file: Drag and Lift Coeff.
saveFlCdCl = 'Save_CdCl.txt'; %File name
finputCdCl = fopen(saveFlCdCl); %Open file for reading
dataBuffer = textscan(finputCdCl, '%f %f %f ', 'CollectOutput', 1, ... %Read data from file
'Delimiter', '', 'HeaderLines', 12);
%Get values
PolarAoA=dataBuffer{1}(:,1);
PolarCl=dataBuffer{1}(:,2);
PolarCd=dataBuffer{1}(:,3);
fclose(finputCdCl); %Close file
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 19 Apr. 2021
%Read data file: Drag and Lift Coeff.
saveFlCdCl = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/586711/Save_CdCl.txt'; %File name
t = readtable(saveFlCdCl, 'readvariablenames', false, 'headerlines', 12);
t.Properties.VariableNames = {'alpha', 'CL', 'CD', 'CDp', 'CM', 'Top_Xtr', 'Bot_Xtr'};
t(1:5,:)
t(end-4:end,:)
Weitere Antworten (1)
David Hill
am 17 Apr. 2021
t=readtable('Save_CdCl.txt');
alpha=t.alpha;
names=t.Properties.VariableNames;
for k=1:length(names)
writetable(t(:,k),names{k});
end
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!