I am a new user of Matlab. So, a kind response will be highly appreciated.
All of my experimental data are saved into a txt file. Now, when I load the file, it gives me only one row without any tab or space. I need to separate the integers. A simple space after 3 integer will do the work. But, the file is huge. It's length is 1182239.
i.e: the data: 008112132143... I want: 008 112 132 143...

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 5월 22일
편집: Azzi Abdelmalek 2013년 5월 22일

0 개 추천

a='123456789'
a=reshape(a,3,[]);
a=[a;blanks(size(a,2))]
a=a(:)'
%or more general
b='1234567'
n=numel(b)
m=ceil(n/3)*3
a=blanks(m);
a(1:n)=b
a=reshape(a,3,[]);
a=[a;blanks(size(a,2))]
a=a(:)'

댓글 수: 1

Saurabh Mahalpure
Saurabh Mahalpure 2022년 4월 25일
How can I do this for big file with bitstream such 1010000010101110001010... upto 5-6lakh binary numbers stream

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

추가 답변 (2개)

Matt J
Matt J 2013년 5월 22일

0 개 추천

See DLMWRITE and DLMREAD
Walter Roberson
Walter Roberson 2013년 5월 22일

0 개 추천

Read in the row as a string, say S.
If you want the result as strings, then
reshape(S, 3, []).'
would give one group of three per row.
If you want the result as integers converted from the strings, then
(S(1:3:end)-'0') * 100 + (S(2:3:end)-'0') * 10 + (S(3:3:end)-'0')
will give you a row vector of integral values.

카테고리

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

질문:

2013년 5월 22일

댓글:

2022년 4월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by