Article View: comp.soft-sys.matlab
Article #16Re: Saving a filename
From: 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
Technical Details
Message-ID:
<maurer.727744994@nova.Stanford.EDU>Path:
arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!nntp.Stanford.EDU!forsythe.stanford.edu!nova!maurerReferences:
<1jpqkjINNb6j@shelley.u.washington.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.soft-sys.matlab Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!nntp.Stanford.EDU!forsythe.stanford.edu!nova!maurer From: Michael Maurer <maurer@nova.stanford.edu> Subject: Re: Saving a filename Message-ID: <maurer.727744994@nova.Stanford.EDU> Sender: news@leland.Stanford.EDU (Mr News) Organization: STAR Lab, Stanford University, California USA References: <1jpqkjINNb6j@shelley.u.washington.edu> Date: 22 Jan 93 23:23:14 GMT Lines: 32