.dat file editing

조회 수: 9 (최근 30일)
Dhyrim
Dhyrim 2017년 5월 3일
편집: John Kelly 2017년 11월 10일
Hi, I need help with some beginner lvl stuff in matlab. I have a .dat file, with 3 colums of long data, that I want to use in another program for research. I would like to open the file, and multiply/add every value of the first column with a fixed number. Then after the values are changed, i would want to save it under a new name, but still as a .dat file, so I can use it outside of matlab. Can anyone help me with this? Thx in advance

답변 (1개)

KL
KL 2017년 5월 3일
편집: KL 2017년 5월 3일
data_in = dlmread('sample.dat');
data_out = [data_in(:,1)*2, data_in(:,2)+4, data_in(:,3)];
save my_data.dat data_out -ASCII
check here
  댓글 수: 10
Dhyrim
Dhyrim 2017년 5월 4일
Its kinda working, I imorted the data and then saved it using the line you proposed. Only problem is, now it saves the numbers in their short form, it cuts it of after a certain decimal.... and I also used format long
KL
KL 2017년 5월 4일
that's surprising. I created my own dat file with few values of similar precision and the import works fine.

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

카테고리

Help CenterFile Exchange에서 Standard File Formats에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by