From help-octave-request at bevo dot che dot wisc dot edu Fri Apr 14 09:38:01 2000 Subject: Re: Running Octave in the background From: Ben Sapp To: bob dot bumala at stanford dot edu CC: help-octave at bevo dot che dot wisc dot edu Date: Fri, 14 Apr 2000 08:37:57 -0600 Bob Bumala wrote: > Hi there, > I've been using the Matlab Engine to display real time data for our > experiment "GLAST". http://glast/ . A real time stream of packets is > archived by a set of programs called SETS, and the packet is placed in > shared memory, where a separate C program extracts the data and sends it > to the Matlab engine for display. > Is it possible to do this with Octave? > How do I invoke the engine? > How do I pass the parameters? Hi Bob, If I understand your problem right you can do it all from Octave. You have a couple of choices. I actually think it would be the most efficient to read in the shared memory directly from Octave and by-pass the seperate C program all together. For example something like the following: --------------------------------------------------------- #include #include #include #include DEFUN_DLD(shm_access,args, ,"Program to access shared memory") { ColumnVector data(size_of_data); open(shared_memory); read(shared_memory_into_the_data_vector); return octave_value(data); } ---------------------------------------------------------- You would put this in a file called shm_access.cc(or whatever the first arguement to DEFUN_DLD was) then you would compile it with 'mkoctfile -v shm_access.cc'. Then you would need to put the shm_access.oct file in your OCTAVE_PATH. Then you could access the data from octave command line like so: octave:1> data = shm_access; octave:2> plot(shm_access); Now, you mentioned a C-program that passes the data to Matlab. I am not exactly sure how, maybe you could explain? If it is by pipes you could simply call your program from Octave and read in the data from stdin like so: octave:1> shm = popen("shm_access","r"); octave:2> data = zeros(1,size_of_data); octave:3> i = 1; octave:4> while (isstr (s = fgets (fid))) data(i) = str2num(s); i++; endwhile octave:5> plot(data); As far as invoking the Octave engine. That is very simple. Once you know the command you want to execute put them in a file. You can run it from the command line like so: octave display_data where display_data is the name of your file. On systems that support it you can also put the following line on the top of the file: #!/path/to/your/octave and then make the file executable(chmod +x display_file) and then runit directly from the command line like so: ./display_file I hope that answers your question. If not, keep asking! I would like to know how this goes Bob. I had not thought of this approach before. I have written a program for a neutrino experiment (http://www.neutrino.lanl.gov/BooNE) that accesses shared memory and display certain information. But, I used Java as the GUI. This is not nearly as flexible as the capabilities of Octave and gnuplot. The only downside is I can not have buttons that say things like "go", "stop" and "pause". Thanks for the idea. :-) -- Ben Sapp Los Alamos National Laboratory email: Phone: (505)667-3277 Fax: (505)665-7920 URL: http://www.neutrino.lanl.gov/ -- ----------------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.che.wisc.edu/octave/octave.html How to fund new projects: http://www.che.wisc.edu/octave/funding.html Subscription information: http://www.che.wisc.edu/octave/archive.html -----------------------------------------------------------------------