How can i reformat matriks from one column to one row
1 view (last 30 days)
Show older comments
Retno Purwaningsih
on 16 Aug 2021
Commented: Retno Purwaningsih
on 18 Aug 2021
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 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on PID Controller Tuning in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!