Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Importing txt file using the importdata comand

조회 수: 1 (최근 30일)
googo
googo 2013년 4월 17일
마감: MATLAB Answer Bot 2021년 8월 20일
Hello,
*1: *
I wrote a function that does some manipulations over a vector strings. Now, I want to apply it on text files.
So let's assume XXX.txt is :
hello world
hello world world
hello world world world
So I wrote:
A = importdata comand ('XXX.txt')
when I run A I get :
A =
'hello world'
'hello world world'
'hello world world'
Now, I want it to be treated as 3 separated vectors of chars. How can I do it? or better question is how to get to one of the vectors? For example: V1 = 'hello world' and V1(1,1)=h
2:
When I tryed to run text files with a lot of text I received this message:
A = importdata('a_lot_of_text.txt')
A =
[1x2568 char]
what does it means? and the first question refers to this also.
Thank's!
  댓글 수: 2
Friedrich
Friedrich 2013년 4월 17일
편집: Friedrich 2013년 4월 17일
When I import the xxx.txt i get what you want right away:
>> A = importdata('XXX.txt')
A =
'hello world'
'hello world world'
'hello world world world'
>> A{1}
ans =
hello world
>> A{1}(1,1)
ans =
h
>> A{1}(1,1:3)
ans =
hel
It seems like that a_lot_of_text.txt has a different format than xxx.txt
googo
googo 2013년 4월 17일
편집: googo 2013년 4월 17일
Thank's.
No,it's a txt also.
It's just a big paragraph. For exmaple, I copied this paragraph to notepad:
The human brain has the same general structure as the brains of other mammals, but is larger than any other in relation to body size. Large animals such as whales and elephants have larger brains in absolute terms, but when measured using the encephalization quotient which compensates for body size, the human brain is almost twice as large as the brain of the bottlenose dolphin, and three times as large as the brain of a chimpanzee. Much of the expansion comes from the part of the brain called the cerebral cortex, especially the frontal lobes, which are associated with executive functions such as self-control, planning, reasoning, and abstract thought. The portion of the cerebral cortex devoted to vision is also greatly enlarged in humans.
I saved it as vvv.txt and wrote:
>> B=importdata('vvv.txt')
B =
[1x749 char]

답변 (0개)

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by