Read table in .txt to MATLAB
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Karl Zammit
el 17 de Abr. de 2021
Comentada: Karl Zammit
el 19 de Abr. de 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 comentarios
Respuesta aceptada
Walter Roberson
el 19 de Abr. de 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,:)
Más respuestas (1)
David Hill
el 17 de Abr. de 2021
t=readtable('Save_CdCl.txt');
alpha=t.alpha;
names=t.Properties.VariableNames;
for k=1:length(names)
writetable(t(:,k),names{k});
end
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!