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 load 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 load string

Hi all,

I have a file contain a line of string. The string contain a continuous '0''1', like'0100011001...'.

How to load the string to matlab?
Any suggestion will be appreciated!

Best regards,
Davy
 

matlab load file string

method 1.
file=input('input filename ','s');
fid=fopen(file);
A=fscanf(fid,'%e %x',[2,inf]); %*** this is what u want
fclose(fid);
method 2. (from HELP of matlab)
The first line of mydata.dat is

Sally Type1 12.34 45 Yes
Read the first line of the file as a free format file using the % format.

[names,types,x,y,answer] = textread('mydata.dat','%s %s %f ...
%d %s',1)
returns

names =
'Sally'
types =
'Type1'
x =
12.34000000000000
y =
45
answer =
'Yes'
 

    davyzhu

    Points: 2
    Helpful Answer Positive Rating
load string matlab

Hi,
I suggest you store the input in binary format and use fread.
Otherwise you can use fscanf.
brmadhukar
 

matlab load file

hai,

there is a direct command in matlab to use it.

text = textread('file_name',%s);

or it can also read the file depending on some delimiter.

text = textread('file_name',%s,'delimiter','\n');

there are many options like this

you can see the help

lakshmish
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top