## Copyright (C) 2009, 2010 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: [v] = gds_wd2val(WDATA, VSCALE)
##
## Returns the Waveform Data WDATA scaled by the Vertical Scale VSCALE,
## taking the GDS-2000 oscilloscope 25 samples/div scaling constant
## into account.
##
## Example:
##
## gs = gds_csvread("DS0012.CSV");
## v = gds_wd2val(gs.Waveform_Data, gds.Vertical_Scale);
##
## See also: gds_struct2val.

## Author: Thomas Weidenfeller
## Created: 2010-07-10
## Version: $Id: gds_wd2val.m,v 1.3 2010/12/31 13:05:40 tw Exp $
## Keywords: Oscilloscope, GDS-2000, gds2000tools, plot

function [v] = gds_wd2val(wd, vs, vp)
	SAMP_DIV = 25;

	if(nargin < 3)
		vp = 0;
		if(nargin < 2)
			print_usage();	
		endif
	elseif(nargin > 3)
		print_usage();
	endif

	v = wd .* vs ./ SAMP_DIV .+ vp;
endfunction

%!demo
%! wd = [0 2.5 5 7.5 10 ];
%! vert_scale = 10;
%! gds_wd2val(wd, vert_scale)
