필터 지우기
필터 지우기

How to put text into an array

조회 수: 2 (최근 30일)
mt
mt 2014년 10월 24일
댓글: Image Analyst 2014년 10월 27일
Hi all,
I have a big text right now and I wish to put every line as an array... could someone help?
201403 0.000 8.333 0.00 0.00
So this is one of the lines of my text, and I wish to sort it as an array like
2014 03 0.000 8.333 0.00 0.00
Can anybody help please?
Thanks!
  댓글 수: 1
per isakson
per isakson 2014년 10월 24일
편집: per isakson 2014년 10월 24일
I don't understand your question. What do the other lines look like and what should happen to them?

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

채택된 답변

per isakson
per isakson 2014년 10월 24일
편집: per isakson 2014년 10월 24일
Hint:
>> str = '201403 0.000 8.333 0.00 0.00';
>> cac = textscan( str, '%4f%2f%f%f%f%f', 'CollectOutput', true )
cac =
[1x6 double]
>> cac{:}
ans =
1.0e+03 *
2.0140 0.0030 0 0.0083 0 0
  댓글 수: 4
mt
mt 2014년 10월 27일
I'm trying to make a loop statement for this one. All the other lines are on these formats as well.
Image Analyst
Image Analyst 2014년 10월 27일
I don't understand the second sentence. What do you mean by "on these formats"? Just call fopen(), have your loop with textscan() inside, then call fclose(). What's the problem you are having? Are we supposed to know what your code is? If so, you'll have to post it.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Text Data Preparation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by