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 >

Réponses (1)

D1 = dlmread('example1.txt');
D2 = dlmread('example2.txt');
M = [D1(:, 1:2) D2];

2 commentaires

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?

Connectez-vous pour commenter.

Catégories

Tags

Question posée :

le 3 Déc 2014

Commenté :

le 4 Déc 2014

Community Treasure Hunt

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

Start Hunting!

Translated by