Thread View: comp.soft-sys.matlab
2 messages
2 total messages
Started by David Hampton
Fri, 22 Jan 1993 21:57
Saving a filename
Author: David Hampton
Date: Fri, 22 Jan 1993 21:57
Date: Fri, 22 Jan 1993 21:57
13 lines
1085 bytes
1085 bytes
I have prompted a user for a data filename using
filename=input('Data file to read: ', 's');
and now I need to do some manipulations on the file to break it
into matrices for Matlab to load. This is most easily done with
shell commands from my m-file, but I have to pass the string in
"filename" to the shell so that I can manipulate the selected file
(Matlab wont export variable values to shell commands).
One way might be to save the filename as
save tmp_file filename -ascii
but this just saves digits for the letters of the filename. Is there
a way to save the actual ascii text to a file?
-- Dave Hampton
Re: Saving a filename
Author: Michael Maurer
Date: Fri, 22 Jan 1993 23:23
Date: Fri, 22 Jan 1993 23:23
32 lines
1780 bytes
1780 bytes
In <1jpqkjINNb6j@shelley.u.washington.edu> dhampton@carson.u.washington.edu (David Hampton) writes:
>I have prompted a user for a data filename using
> filename=input('Data file to read: ', 's');
>and now I need to do some manipulations on the file to break it
>into matrices for Matlab to load. This is most easily done with
>shell commands from my m-file, but I have to pass the string in
>"filename" to the shell so that I can manipulate the selected file
>(Matlab wont export variable values to shell commands).
>One way might be to save the filename as
> save tmp_file filename -ascii
>but this just saves digits for the letters of the filename. Is there
>a way to save the actual ascii text to a file?
Try using the 'eval' command in matlab:
filename=input('Data file to read: ', 's');
shcmd=['!matcvt ' filename ' > tmp.mat'];
eval(shcmd)
load tmp.mat
delete tmp.mat
where 'matcvt' is a shell command that takes as first argument the input
filename and writes a matlab file on the standard output. Then the
results of this are available in 'tmp.mat'.
I've found 'eval' to be indispensable when interacting with the shell.
-Michael
--
______________________________________________________________________
Michael Maurer maurer@nova.stanford.edu (415) 723-1024
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads