Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Loading/read problems with tsv files in Matlab

826 views
Skip to first unread message

Raady

unread,
Feb 1, 2011, 10:54:04 AM2/1/11
to

I am trying to load files with file extension .tsv

I used a activex control in my guide, and added a functionality for double click using a command "uigetfile" to browse the file.
I could retrive filename, pathname, filterindex through this command.

I am stuck up with loading the file to do my manuplations, any suggestion would be helpful.
My tsv file contains like 30 columns and huge number of rows,
example
mon tue wed thu ...
100 200 300 400..
...

I need to read the first line of the matrix in text.
I tried to use with textread function , but i get errors.

Any suggestions with matlab or gui would be helpful.

John

unread,
Feb 1, 2011, 11:13:04 AM2/1/11
to
Hi,

What is the delimiter in your file?

And which error do you get?

You can try to use textscan to read the text files.

fid = fopen('Your_file.tsv');
C = textscan(fid, 'format');

in your case, format is going to be "%s";

ImageAnalyst

unread,
Feb 1, 2011, 12:02:49 PM2/1/11
to
I assume tsv means tab separated variables.
Have you tried dlmread with a tab as the delimiter?

TideMan

unread,
Feb 1, 2011, 4:32:10 PM2/1/11
to
On Feb 2, 6:02 am, ImageAnalyst <imageanal...@mailinator.com> wrote:
> I assume tsv means tab separated variables.
> Have you tried dlmread with a tab as the delimiter?

But dlmread docs say specifically that dlmread won't read files
containing non-numeric data like the OP has in the header.

OP needs to use textscan.
Read the first row with a sequence of %s (one for each column), then
read the rest of the file with %f (one for each column).
header=textscan(fid,repmat('%s',1,ncol),1,'delimiter','\t');
data=testscan(fid,repmat('%f',1,ncol),'delimiter','\t');

Raady

unread,
Feb 16, 2011, 8:32:04 AM2/16/11
to
TideMan Thank you , it gets loaded !
0 new messages