Missing new line after Datapair
Mostrar comentarios más antiguos
The output of my Data is messed up, i get the following output
30.0000 22.73685730.2500 22.21240530.5000 22.25532930.7500 22.93022431.0000 22.481385
but i want
30.0000 22.736857
30.2500 22.212405
30.5000 22.255329
30.7500 22.930224
31.0000 22.481385
my code is the following:
%% Import data from text file
% Script for importing data from the following text file:
%
% filename:
% \\Dedosan001\vol1\E\EMV\Kularia\Matlabprogramm\04_Messungen\04\Ergebnistabelle_AV.asc
%
% Auto-generated by MATLAB on 06-Apr-2023 11:22:46
%% Set up the Import Options and import the data
opts = delimitedTextImportOptions("NumVariables", 9, "Encoding", "UTF16-LE");
% Specify range and delimiter
opts.DataLines = [30, 711];
opts.Delimiter = "\t";
% Specify column names and types
opts.VariableNames = ["Frequenz", "PK_MAXH", "Var3", "Var4", "Var5", "Var6", "Var7", "Var8", "Var9"];
opts.SelectedVariableNames = ["Frequenz", "PK_MAXH"];
opts.VariableTypes = ["double", "double", "string", "string", "string", "string", "string", "string", "string"];
% Specify file level properties
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";
% Specify variable properties
opts = setvaropts(opts, ["Var3", "Var4", "Var5", "Var6", "Var7", "Var8", "Var9"], "WhitespaceRule", "preserve");
opts = setvaropts(opts, ["Var3", "Var4", "Var5", "Var6", "Var7", "Var8", "Var9"], "EmptyFieldRule", "auto");
% Import the data
ErgebnistabelleAV1 = readtable("\\Dedosan001\vol1\E\EMV\Kularia\Matlabprogramm\04_Messungen\04\Ergebnistabelle_AV.asc", opts);
%% Clear temporary variables
clear opts
% Speichern der ersten beiden Spalten in einer neuen Datei
outputFilePath = '\\DEDOSAN001\vol1\E\EMV\Kularia\Matlabprogramm\15\1_2.asc';
fileID = fopen(outputFilePath, 'w');
for i = 1:size(ErgebnistabelleAV1, 1)
% Format für Frequenz ohne wissenschaftliche Schreibweise und mit 3 Dezimalstellen
fprintf(fileID, '%0.4f\t%f\n', ErgebnistabelleAV1.Frequenz(i), ErgebnistabelleAV1.PK_MAXH(i));
fprintf(fileID, '\n'); % Neue Zeile nach jedem Datenpaar
end
fclose(fileID);
2 comentarios
Mathieu NOE
el 11 de Abr. de 2023
hello
it would help to have the data file as well (Ergebnistabelle_AV.asc)
Nainpreet
el 11 de Abr. de 2023
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Text Files en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!