home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / softsys / matlab / 116 < prev    next >
Encoding:
Text File  |  1993-01-23  |  1.7 KB  |  44 lines

  1. Newsgroups: comp.soft-sys.matlab
  2. Path: sparky!uunet!stanford.edu!nntp.Stanford.EDU!forsythe.stanford.edu!nova!maurer
  3. From: Michael Maurer <maurer@nova.stanford.edu>
  4. Subject: Re: Saving a filename
  5. Message-ID: <maurer.727744994@nova.Stanford.EDU>
  6. Sender: news@leland.Stanford.EDU (Mr News)
  7. Organization: STAR Lab, Stanford University, California USA
  8. References: <1jpqkjINNb6j@shelley.u.washington.edu>
  9. Date: 22 Jan 93 23:23:14 GMT
  10. Lines: 32
  11.  
  12. In <1jpqkjINNb6j@shelley.u.washington.edu> dhampton@carson.u.washington.edu (David Hampton) writes:
  13.  
  14. >I have prompted a user for a data filename using 
  15. >   filename=input('Data file to read: ', 's');
  16. >and now I need to do some manipulations on the file to break it
  17. >into matrices for Matlab to load.  This is most easily done with
  18. >shell commands from my m-file, but I have to pass the string in 
  19. >"filename" to the shell so that I can manipulate the selected file
  20. >(Matlab wont export variable values to shell commands).
  21. >One way might be to save the filename as
  22. >  save tmp_file filename -ascii
  23. >but this just saves digits for the letters of the filename.  Is there
  24. >a way to save the actual ascii text to a file?
  25.  
  26. Try using the 'eval' command in matlab:
  27.  
  28. filename=input('Data file to read: ', 's');
  29. shcmd=['!matcvt ' filename ' > tmp.mat'];
  30. eval(shcmd)
  31. load tmp.mat
  32. delete tmp.mat
  33.  
  34. where 'matcvt' is a shell command that takes as first argument the input
  35. filename and writes a matlab file on the standard output.  Then the
  36. results of this are available in 'tmp.mat'.
  37.  
  38. I've found 'eval' to be indispensable when interacting with the shell.
  39.  
  40. -Michael
  41. --
  42. ______________________________________________________________________
  43. Michael Maurer          maurer@nova.stanford.edu        (415) 723-1024
  44.