How to replace the data in one column with another column
2 views (last 30 days)
Show older comments
I have this file in text format that contains a data table (see example 1). I want keep column 1 and 2, but replace column 3 and 4 with another set of data (see example 2). the format in example 1 would be keep as it, the number however needs to be replace. For example: < +000.0 +000.0 +000.3 +052.2> would become < +000.0 +000.0 +000.025009 +041.830138>
Example 1
< +000.0 +000.0 +000.0 +051.4 >
< +000.0 +000.0 +000.3 +052.2 >
Example 2
0.000000 38.370049
0.025009 41.830138
Example 3
<+000.0 +000.0 +000.000000 +038.370049 >
<+000.0 +000.0 +000.025009 +041.830138 >
0 Comments
Answers (1)
Thorsten
on 3 Dec 2014
D1 = dlmread('example1.txt');
D2 = dlmread('example2.txt');
M = [D1(:, 1:2) D2];
2 Comments
Thorsten
on 4 Dec 2014
My code allows you to generate your example3 from example1 and example2, as defined in your question. Or does this not work for you? Or what else do you want to achieve?
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!