From help-octave-request at octave dot org Sun Apr 25 22:58:36 2004 Subject: Re: How to keep print compatiable with MATLAB From: Joe Koski To: Octave Help Date: Sun, 25 Apr 2004 21:57:45 -0600 on 4/25/04 9:02 PM, David Bateman at David dot Bateman at motorola dot com wrote: > According to Etienne Grossmann (on 04/25/04): >> >> Hello, >> >> what about sthing like: >> >> if exist ("octave_config_info") >> ## Octave code >> else >> ## Matlab code >> end > > I prefer to test for OCTAVE_VERSION, but hey. You might need to also > use "eval" of functions that exist in Octave and not matlab and > vis-a-versa to avoid parse errors. For instance your example would > become > > if exist ("octave_config_info") > %plot frequency response > N = 16634; > [h, f] = freqz(B, A, N, fs); > eval('gset terminal windows'); > eval('gset title "A-weighting Cureve Frequecny Response"'); > eval('gset grid'); > eval('gset nokey'); > semilogx(f, 20*log10(abs(h))); > > %print plot to PNG pic file > eval('gset terminal png'); > eval('gset output "myplot.png"') > replot > else > % Matlab code > end > Just a quick observation. If Octave and Matlab were compiled instead of interpreted, this approach wouldn't be possible at all. A compiler would choke when it saw the other language's instruction set in the if statement. Are there potential syntax checking problems that could derail this approach? Joe Koski ------------------------------------------------------------- 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 -------------------------------------------------------------