Re: Number to vectors
- From: dpb <none@xxxxxxx>
- Date: Mon, 19 Oct 2009 13:06:43 -0500
someone wrote:
"adam " <unique.pq@xxxxxxxxx> wrote in message <hbi7h5$1n3$1@xxxxxxxxxxxxxxxxxx>...Both your version would work, thanks
But I still got the problem because my number has got a lot of digits (I'm talking of like a million digits).
What I got is a txt file with a lot 0 and 1 but there is no spacing between them and I need to seperate them.
If I create a MATLAB variable with it it deletes a lot of digites as the variable cannot hold so many digits...
Is there any other way to do it? Maybe not in MATLAB but somewhere else? I tried MS Word Replace all and just add a , after every 1 and 0 but as it's 163 pages full of digits it hangs...
Anyone got an idea?
% Without knowng more about the file format, try:
doc fread
doc fgetl
doc textscan
% Look at the Examples and see if any apply to your problem.
% Also look at the See Also section for other ideas.
More than likely fgetl won't help as I'd presume there are no linefeeds.
Something otoo
fid=fopen(filename,'rt');
while ~feof(fid)
s = fread(fid, 1024)';
v = [v double(char(s-'0'))];
end
The above will need several details including the last partial buffer assuming not multiple of the (assumed) 1024 and preallocating v to avoid the runtime overhead therein.
But, the idea is to slurp up a piece of the file at a time as characters, and convert to double a character at a time.
If memory really is a problem, instead of concatenating, write out the digits to a binary file (or text w/ delimiters or whatever is wanted/needed) so it can be processed however later.
In that case, of course, one will undoubtedly need to be able to do the processing piecemeal as well.
W/ no more information than given, what is needed is back into the crystal ball region and mine is _still_ in the shop... :(
--
Will
.
- Follow-Ups:
- Re: Number to vectors
- From: adam
- Re: Number to vectors
- References:
- Number to vectors
- From: adam
- Re: Number to vectors
- From: Wayne King
- Re: Number to vectors
- From: adam
- Re: Number to vectors
- From: someone
- Number to vectors
- Prev by Date: ??? Unrecognized assertion predicate 'strcmp'/ Embedded Matlab Error
- Next by Date: Re: Name of m-file currently being edited (not run)
- Previous by thread: Re: Number to vectors
- Next by thread: Re: Number to vectors
- Index(es):
Relevant Pages
|