## 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: [WDATA] = gds_val2wd(VAL, VSCALE)
##
## Returns the values VAL scaled by VSCALE, so they can be used
## as Waveform Data in a GDSSTRUCT.
## The function takes the GDS-2000 oscilloscope 25 samples/div scaling
## constant into account.
##
## Example:
##
## gs.Waveform_Data = gds_val2wd(v, gs.Vertical_Scale);
##
## See also: gds_wd2val.

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

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

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

	wd = (v .- vp) .* SAMP_DIV ./ vs;
endfunction

%!demo
%! v = [0 1 2 3 4];
%! vert_scale = 10;
%! gds_val2wd(v, vert_scale)
