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
|