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

fullfile sucks!!!!!!!!!!!!

61 views
Skip to first unread message

Baha Kuzu

unread,
Jan 15, 2012, 10:14:09 PM1/15/12
to
I am trying to read thousands of files from web. But matlab "fullfile" does not allow for that because it changes forward slashes (" / ") to back slashes (" \ "), so this blocks urlread command to proceed. Example is below.
__________________________________
fname = 'HELENA/A-HMC180.at2';
[pathstr, name, ext] = fileparts(fname);
ext = '.AT2';
fname_url = fullfile(pathstr,[name ext]);
initial = 'http://peer.berkeley.edu/nga_files/ath/';
record_URL1 = urlread(fullfile('http://peer.berkeley.edu/nga_files/ath/', fname_url));
___________________________________
Gives error, because of the backslashes.
Anything to figure this out appreciated...

TideMan

unread,
Jan 15, 2012, 10:51:19 PM1/15/12
to
Just use square brackets:
fname_url=[pathstr name ext];

Baha Kuzu

unread,
Jan 15, 2012, 11:10:09 PM1/15/12
to
thanks for your reply.

But, what does it change? I still need the forward slash in the directory!!!

ImageAnalyst

unread,
Jan 16, 2012, 12:08:00 AM1/16/12
to
So just change it back to forward slashes. I tried this and it worked
fine:

fname = 'HELENA/A-HMC180.at2';
[pathstr, name, ext] = fileparts(fname)
ext = '.AT2';
fname_url = fullfile(pathstr,[name ext])
initial = 'http://peer.berkeley.edu/nga_files/ath/'
site = fullfile('http://peer.berkeley.edu/nga_files/ath/', fname_url)
% Now change \ back to /
site = strrep(site, '\', '/')
record_URL1 = urlread(site)

Baha Kuzu

unread,
Jan 16, 2012, 12:47:08 AM1/16/12
to
Thank you "image analyst." This is a very good way. Also, instead of using fullfile, just using [] also works. Second belated appreciation to Tideman...

Steven_Lord

unread,
Jan 16, 2012, 9:25:11 AM1/16/12
to


"Baha Kuzu" <ibah...@gmail.com> wrote in message
news:jf04m1$6ig$1...@newscl01ah.mathworks.com...
> I am trying to read thousands of files from web. But matlab "fullfile"
> does not allow for that because it changes forward slashes (" / ") to back
> slashes (" \ "), so this blocks urlread command to proceed. Example is
> below.

That is the expected behavior; FULLFILE is intended for use with _filenames_
not URLs and it uses the appropriate file separator for your OS.

http://www.mathworks.com/help/techdoc/ref/fullfile.html

"Build full *_FILE_* name from parts" [Emphasis mine.]

> __________________________________
> fname = 'HELENA/A-HMC180.at2';
> [pathstr, name, ext] = fileparts(fname); ext = '.AT2'; fname_url =
> fullfile(pathstr,[name ext]);
> initial = 'http://peer.berkeley.edu/nga_files/ath/'; record_URL1 =
> urlread(fullfile('http://peer.berkeley.edu/nga_files/ath/', fname_url));
> ___________________________________
> Gives error, because of the backslashes. Anything to figure this out
> appreciated...

As others have said, use [] to concatenate the pieces of your URL together,
like:

URL = [initial fname]

--
Steve Lord
sl...@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

0 new messages