## Copyright (C) 2009 Thomas Weidenfeller
## 
## This file is part of gds2000tools/gds-octave.
## 
## gds2000tools/gds-octave is free software: you can redistribute it
## and/or modify it under the terms of the GNU General Public License
## version 3 as published by the Free Software Foundation.
## 
## gds2000tools/gds-octave is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
## 
## You should have received a copy of the GNU General Public License
## along with gds2000tools/gds-octave.  If not,
## see <http://www.gnu.org/licenses/>.
##

## usage: [DC] = gds_dc(GDSSTRUCT)
##
## Returns the scalar value of the DC component of the signal in Volts.
##
## Example:
##
## gs = gds_csvread("DS0008.CSV");
## gds_dc(gs)
##
## See also: gds_csvread, gds_csvwrite, gds_ac.

## Author: Thomas Weidenfeller
## Created: 2009-07-08
## Version: $Id: gds_dc.m,v 1.6 2010/12/31 13:05:40 tw Exp $
## Keywords: Oscilloscope, GDS-2000, gds2000tools, AC, DC

function dc = gds_dc(gs)

	if(nargin != 1 || !isstruct(gs))
		print_usage();
	endif

	dc = gds_wd2val(mean(gs.Waveform_Data), gs.Vertical_Scale);
endfunction

%!demo
%! ##gs = gds_csvread("DS0008.CSV"); ## read waveform from file
%! gs = __gds_demo_gs();  ## for now get a demo gds waveform data structure
%! printf("%f %s\n", gds_dc(gs), gs.Vertical_Units);
