help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to keep print compatiable with MATLAB


From: Fredrik Lingvall
Subject: Re: How to keep print compatiable with MATLAB
Date: Mon, 26 Apr 2004 10:27:45 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040130

David Bateman wrote:
According to Etienne Grossmann <address@hidden> (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


  
An alternative is use octave-forge and,
%plot frequency response
N = 16634;
[h, f] = freqz(B, A, N, fs);
title('A-weighting Cureve Frequecny Response');
grid('on');
legend('off');
semilogx(f, 20*log10(abs(h)));
 
%print plot to PNG pic file
print('-dpng','myplot.png');

which should work in both Octave and Matlab.

Fredrik

reply via email to

[Prev in Thread] Current Thread [Next in Thread]