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] How to read lines of vector or string from 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 read string

Hi all,

1) How to read lines of vector from file?
For example,
I have a file:
12 45 78 41 54 78 41 74 57 84
43 54 84 54 78 74 57 12 45 45
41 85 12 45 45 43 54 84 45 78
How to read one line each time?

2) How to read lines of string from file?
For example,
I have a file:
100110101010100101101000110001
101100110110100101120010111010
010100101011000101101010101001
How to read one line each time?

Any suggestions will be appreciated!

Best regards,
Davy
 

matlab read line

Are those ASCII text files?

Read the files into what? Character arrays? Integer arrays?

Is your second example suppose to be binary? Why is there a '2' in there?
 

matlab read line by line

Hi,

They are ASCII files. Read the files into integer arrays.
And the '2' should be '1'.

Thanks!
Davy
 

matlab read file line by line

Still not too clear what you need. What does "one line each time" mean? Maybe show us what the MATLAB arrays should contain after reading the file.

Maybe one of these functions will help: fscanf, dlmread, textread, textscan
 

matlab read vector from file

Hi echo47,

Maybe there is a FOR loop.

For i=1:3
%when i=1
% vector1=[12 45 78 41 54 78 41 74 57 84];
%when i=2
% vector1=[43 54 84 54 78 74 57 12 45 45];
%... ...
%when i=1
% vector2=[1 0 0 1 1 0 1 0 1 0 1 0 1 0 0 1 0 1 1 0 1 0 0 0 1 1 0 0 0 1 ];
%... ...

end

BTW, I like the SAVE, LOAD command. But they seems load the matrix once. And I want to load a line of vector once.

Thanks!
Davy
 

matlab read string from file

Dear davy,
I cannot get what u really want but i think this may help
write in the workspace "lookfor iofun", this will search for all input output functins supported in matlab & among which that supports file reading.
 

reading line by line in matlab

Hi,
i am nwe in this filed and i'd like to know how can i read ip number from a text file like this one below.
1236115462.507184,0.658182,0.146736,195.251.123.232,208.083.139.204,36557,2703,7,506,8,482

I had tried with the 'textread' command in MatLab but i believe that i do something wrong...

If anyone can do something...

Thanks in advance...
 

matlab find string in file

hi my friend,

did you asked the matlab groupnews?

i am sure you will find the answer
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top