From: Judas Magnus on
hmm im trying to find the number of lines the the text document.

Using your while loop i can easily do it with size(TheCellArray) which I get

1 20

*So 20 lines

However, working with ShortStory.txt which is opened with
T= fopen('ShortStory.txt','rt')
when I use

T1 =size(T)


I get like

1 1


which doesn't make sense to me, the total lines of the cell array and txt should be the same....
From: Walter Roberson on
Judas Magnus wrote:
> hmm im trying to find the number of lines the the text document.
>
> Using your while loop i can easily do it with size(TheCellArray) which I
> get
>
> 1 20
>
> *So 20 lines

Yes, that would be an appropriate way

> However, working with ShortStory.txt which is opened with T=
> fopen('ShortStory.txt','rt')
> when I use
> T1 =size(T)
>
>
> I get like
> 1 1
>
>
> which doesn't make sense to me, the total lines of the cell array and
> txt should be the same....

Remember what I wrote earlier, that what is returned by fopen is just a
file identifier, which is a simple number such as 3 . The file
identifier has no meaning on its own, but it is used by the I/O routines
to as the indicator of _which_ file you want to work with, without
having to re-specify the file information for each operation.

Like when you drive your car into a mechanic, they record all kinds of
information about the owner, model, license plate, vehicle
identification number, odometer reading, and what-not -- but once that
is done, what the mechanic gets told is "the car in bay #3 needs its oil
changed". The bay number gets used as the reference identifier for which
vehicle needs to be operated on, but the size of the bay _number_ has
nothing to do with the size of the _vehicle_ or how many rows of seats
it has.