Re: Function that calls plot
Daniel J Sebald <[email protected]> Sun, 02 Jul 2006 14:39:22 -0500
| Newsgroups | gmane.comp.gnu.octave.graphics |
|---|---|
| Message-ID | <[email protected]> |
Andnan wrote:
> I'm trying to make a FFT plotting function that's a little better then
> gplot(abs(fft));
>
> I want the frequency axis centered at 0 and I want the frequency axis
> normalized.
>
> My probelm is that I want to pass the name of the file to save to plot to as
> a parameter and I can't get it working. Here's my code.
>
> function OctaveFFTPlot(x,file_name)
> clf;
> grid on; #turn on the grid
>
> # Amplitude plot
> yLabel('Amplitude'); #Set the y axis
>
> fft_data = fft(x); #do an FFT on the sample data
>
> fftshift(fft_data);
>
> # create a normaized frequency axis for the plot
> normal_f=(1:length(fft_data))./ length(fft_data);
> normal_f = normal_f.-0.5;
>
> plot(normal_f,abs(fft_data));
> gset out file_name;
> gset terminal gif;
> replot;
> closeplot;
> end;
>
> It is not saving the file to the file_name.
>
> any Ideas?
Andnan,
You are working with a fairly old version of octave. "gset" has been moved to "__gnuplot_raw__()". In any case, perhaps you need some quotations around the file name. The equivalent gnuplot command is:
set output 'filename.gif'
and you may be sending it a command like
set output filename.gif
which would error in gnuplot. Something like
eval(["set out '" file_name "'"]);
or some variation thereof might do thet trick.
Also, try to put the "set out" after the "set term". I don't think order matters in gnuplot anymore, but it once did.
Dan