How to replace the data in one column with another column

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 >

답변 (1개)

Thorsten
Thorsten 2014년 12월 3일
D1 = dlmread('example1.txt');
D2 = dlmread('example2.txt');
M = [D1(:, 1:2) D2];

댓글 수: 2

this wont help much, since i need to data to be replaced but still keeping the formating
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?

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Tables에 대해 자세히 알아보기

태그

질문:

2014년 12월 3일

댓글:

2014년 12월 4일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by