Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Regrouping data into text
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
I'm trying to create an section of an input file that requires a specific formatting. The data is in 2 separate text files and I need to put it in one single text file with the following format:
first line=a{i,1}
second line=b{i,1}
third to +n line=d{i,1}
and repeat
first line=a{i,1}
second line=b{i,1}
third to +c line=d{i,1}
Here is the code I've been working on to try and do this but it does no work when printing to text. Any comments will be greatly appreciated. Thanks!
if true
clear all
clc
A1=importdata('CROSS_SECTIONS1.txt');
A2=importdata('CROSS_SECTIONS2.txt');
GR=A1.textdata{:,5};
Elevation=A1.data(:,3);
Elev_Station=A1.data(:,2);
Station1=A1.data(:,1);
X1=A2.textdata{:,1};
NC=A2.textdata{:,2};
Station2=A2.data(:,1);
StationCount=A2.data(:,2);
R_bankSt=A2.data(:,3);
L_bankSt=A2.data(:,4);
n1=A2.data(:,5);
n2=A2.data(:,6);
n3=A2.data(:,7);
A=[Station1 Elevation];
A = sortrows(A,1);
idx = cumsum(diff([0;A(:,1)])>0);
idxn = histc(idx,unique(idx));
C = mat2cell(A,idxn,size(A,2));
for i=1:length(n1)
a{i,1}={NC n1(i) n3(i) n2(i)};
b{i,1}={X1, Station2(i) StationCount(i) L_bankSt(i) R_bankSt(i) 0 0 0 0 0};
d{i,:}={C{i,:}};
fileID{i} = fopen('cross_sections.txt','a+');
fprintf(fileID{i},'%s\n',a{i,1});
fprintf(fileID{i},'%s\n',b{i,1});
fprintf(fileID{i},'%s\n',d{i,1});
fclose(fileID{i});
end
end
0 comentarios
Respuestas (0)
La pregunta está cerrada.
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!