From help-octave-request at bevo dot che dot wisc dot edu Wed Feb 4 22:18:07 2004 Subject: Re: Tip for loading Excel Spreadsheet into Octave on Mac From: Joe Koski To: Octave_post Date: Wed, 04 Feb 2004 21:14:18 -0700 Nice tip Henry. I'll put it in my tips file. On a related subject, is there an easy, quick way in Octave of reading several side-by-side data columns into separate column vectors, i. e., from an Excel spreadsheet? I recently resorted to placing [t(i) x(i)] = fscanf(fileid,"%f%f","C"); inside a while loop with feof in order to read two columns of data. Is there a way of reading column-by-column data without first reading the entire data file into a single matrix, and then copying the columns (or rows) of the matrix into separately named vectors? (This is, by the way, what we resorted to with the MATLAB version of the data routine, which couldn't understand the "C" option for fscanf.) I guess the easy-to-use Excel and Kaleidagraph data import gui features have spoiled me. Thanks for any advice. Joe Koski on 2/4/04 8:02 PM, Henry F. Mollet at mollet at pacbell dot net wrote: > There may be more sophisticated ways to get an Excel Spreadsheet into Octave > on Mac but this works for me and I don't have to explicitly change the > carriage return (\r) of Mac OS into newline (\n) of Unix. I suggest that > this is suitable for medium sized data matrices, which would be cumbersome > to enter in octave at the command line prompt but not that large that a > spreadsheet wouldn't really work either. > > Copy your spreadsheet (I'm using Excel) and paste it into BBEdit Lite 6.1 > for OS X. BBEdit has a Unix save/save as option. Octave will load this file: > > octave:83> load Test&testfile > octave:84> whos > *** local user variables: > prot type rows cols name > ==== ==== ==== ==== ==== > rwd matrix 39 7 Test_testfile > Octave even takes care of the "&" in the filename and renames the matrix but > it cannot handle a space. > > Now the name of the matrix "Test_testfile" can be changed to say > "InputMatrix" (so it will the same as in the script which will use the file) > octave:92> InputMatrix=Test_testfile > > Now the file can be saved with the same name *in octave* > octave:94> save Test&testfile InputMatrix > > BBEdit will even automatically amend the file with > # Created by Octave 2.1.46, Wed Feb 04 18:50:05 2004 PST > > # name: InputMatrix > # type: matrix > # rows: 39 > # columns: 7 > Henry > > > > ------------------------------------------------------------- > Octave is freely available under the terms of the GNU GPL. > > Octave's home on the web: http://www.octave.org > How to fund new projects: http://www.octave.org/funding.html > Subscription information: http://www.octave.org/archive.html > ------------------------------------------------------------- > ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------