From help-octave-request at bevo dot che dot wisc dot edu Wed Dec 19 13:08:36 2001 Subject: Re: Is there an Octave equivalent to the Matlab ASSIGNIN function? From: Paul Kienzle To: =?iso-8859-1?Q?P=E5l_Frenger?= , help-octave@bevo.che.wisc.edu Date: Wed, 19 Dec 2001 14:08:29 -0500 It should be possible to write assignin('base',n,V) as a .cc file by adding or modifying the variable in top_level_sym_tab. Alternatively, you could use eval(['global ', n, '; ', n, '=V;']) but you will need to define the variable as global in the top level context to access it. There is no way to write assignin('caller',...) without modifying the octave interpreter. To get the effect of assignin('caller',...), you could write my_load so that it returns a structure and expand the structure using: for [key,val] = my_load(...) eval([key "=val;"]); end Or you could write my_load as a script (not a function!!) which expects the name of the file to be in a particular variable before it is invoked. You have to be a lot more careful with your variables in the my_load script, though, since they might collide with those in the "caller". Or you could use the global variable solution I suggested for 'base'. Paul Kienzle pkienzle at users dot sf dot net On Wed, Dec 19, 2001 at 12:00:19PM -0600, Pål Frenger wrote: > > This is a multi-part message in MIME format. > --------------0B8CAC64C1C813BB4BA6A531 > Content-Type: text/plain; charset=iso-8859-1 > Content-Transfer-Encoding: 8bit > > Hi, > > I have a lot of binary files that I have created using C++. I have written a function "my_load.m" > that reads this binary file format into Matlab. Now I want to convert "my_load.m" so that it works > also in Octave. Therefore I need something similar to the Matlab assignin function: > > >help assignin > > > > ASSIGNIN Assign variable in workspace. > > ASSIGNIN(WS,'name',V) assigns the variable 'name' in the > > workspace WS the value V. WS can be one of 'caller' or 'base'. > > Is there any Octave equivalent to this function, or any work-around, that I can use to get my > variables from the file into Octave? > > Grateful for any help on this topic. > > //Pål Frenger > > --------------0B8CAC64C1C813BB4BA6A531 > Content-Type: text/x-vcard; charset=us-ascii; > name="pal.frenger.vcf" > Content-Transfer-Encoding: 7bit > Content-Description: Card for Pål Frenger > Content-Disposition: attachment; > filename="pal.frenger.vcf" > > begin:vcard > n:Frenger;Pål > tel;cell:+47 (0)709 783 444 > tel;fax:+46 (0)8 585 314 80 > tel;home:+46 (0)8 624 30 70 > tel;work:+46 (0)8 75 70 152 > x-mozilla-html:FALSE > url:http://eratu.ericsson.se/users/erapall/ > org:Ericsson Research;Ericsson Radio Systems AB > adr:;;Torshamnsgatan 23, Kista KI/ERA/T/UR;;;SE-164 80;Sweden > version:2.1 > email;internet:pal dot frenger at era dot ericsson dot se ICQ: 17558425 > title:Ph.D. > note:Private email: pal dot frenger at passagen dot se > x-mozilla-cpt:;20624 > fn:Pål Frenger > end:vcard > > --------------0B8CAC64C1C813BB4BA6A531-- > > > > ------------------------------------------------------------- > 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 -------------------------------------------------------------