How can i reformat matriks from one column to one row
조회 수: 1 (최근 30일)
이전 댓글 표시
I have data like this in many file
File 222
222 -10.894943 127.960434 0.0136
222 -10.994533 127.997716 0.0163
File 223
223 -10.944739 127.979071 0.0272
223 -11.044324 128.016368 0.0217
223 -11.143902 128.053696 0.0448
From that data i want to be like this
File 222
222 -10.894943 127.960434 0.0136 0.0163
File 223
223 -10.944739 127.979071 0.0272 0.0217 0.0448
I just want the first row and the next column is the value of column 4 so on, the corresponding row (except first row) need to be eliminated.
First i define each column, and than transpose column 4 but it doesn't work
clc;
clear;
format short;
f =dir('D:\MATLAB\table_*.txt');
for A=1:length(f);
D=f(A).name;
ff=D(:,7:9)
data=load(D);
ref=data(:,1);
lat=data(:,2);
lon=data(:,3);
data1=data(:,4);
tr=data1'
row1=data(,:1);
col1=row1(:,1);
col2=row1(:,2);
col3=row1(:,3);
final=[col1 col2 col3 tr]
%save file
file_name = sprintf('Table_' ff 'fix.txt');
dlmwrite(file_name,final,'delimiter','\t','precision',10);
end
댓글 수: 0
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 PID Controller Tuning에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!