Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[Matlab]Load each line of string separately (from a file) ?

Status
Not open for further replies.

davyzhu

Advanced Member level 1
Joined
May 23, 2004
Messages
494
Helped
5
Reputation
10
Reaction score
2
Trophy points
1,298
Location
oriental
Activity points
4,436
matlab load string

Hello all,

I have a file contain several lines of strings(all the digit is in ASCII mode).
The file's content is like below, each line is a string:
0101010101010101
1010101010101010
0011001100110011
... ...
But my real string each line is 1*2000, and I have 4000 lines strings.

How to load each line of string separately?
i.e. load line1 string -> load line2 string -> ...till the last line string

Thanks!
Richard
 

matlab sting matrix load

Please clarify what type of matrix you want to load the file into.

How about this?
foo = textread('mydata', '%s');

Or maybe this?
foo = cell2mat(textread('mydata', '%s'));

Those both work with 4000x2000 character files.
 

matlab each line

Hi echo47,

I am confused with this operation ;-)

Loading the matrix consumes too many ram. And load all the matrix is not necessary for my job.

Each line of the matrix is a codeword received from the channel. So I have to decode a codeword each time(Not necessary load all the codeword).

So what I want is dealing with rows of the matrix(i.e. the row vector of the matrix).

For example,
at time1, load the row 1(string) from matrix file, decode the code word 1;
at time2, load the row 2(string) from matrix file, decode the code word 2;
... ...

Sorry for my poor English,

Best regards,
Davy
 

matlab load string

Oh I see! You want a loop that reads one line from the file per loop iteration.

How about this?

Code:
fin = fopen('mydata');
while ~feof(fin)
  foo = fgetl(fin);
  disp(foo);    % replace this with your line parsing code
end
fclose(fin);
 

    davyzhu

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top