text:
%MDL_SIMPLE6 A minimalistic 6DOF robot arm
%
% MDL_SIMPLE6 is a script creates the workspace variable s6 which describes
% the kinematic characteristics of a simple arm manipulator with a
% spherical wrist and no shoulder offset, using standard DH conventions.
%
% Also define the workspace vectors:
%   qz         zero joint angle configuration
%
% Notes::
% - Unlike most other mdl_xxx scripts this one is actually a function that
%   behaves like a script and writes to the global workspace.
%
% See also mdl_offset6, mdl_puma560, SerialLink.

% MODEL: generic, 6DOF, standard_DH

% Copyright (C) 1993-2017, by Peter I. Corke
%
% This file is part of The Robotics Toolbox for MATLAB (RTB).
%
% RTB is free software: you can redistribute it and/or modify
% it under the terms of the GNU Lesser General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% RTB 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 Lesser General Public License for more details.
%
% You should have received a copy of the GNU Leser General Public License
% along with RTB.  If not, see <http://www.gnu.org/licenses/>.
%
% http://www.petercorke.com

function r = mdl_simple6()

    % robot length values (metres)
    L1 = 1;
    L2 = 1;

    % and build a serial link manipulator

    robot = SerialLink([
        Revolute('alpha', pi/2, 'a', 0,  'd', 0)
        Revolute('alpha', 0,     'a', L1, 'd', 0)
        Revolute('alpha', -pi/2,  'a', L2, 'd', 0)
        Revolute('alpha', -pi/2, 'a', 0,  'd', 0)
        Revolute('alpha', pi/2,  'a', 0,  'd', 0)
        Revolute('alpha', 0,     'a', 0,  'd', 0)
        ], ...
        'name', 'Simple6');

    % place the variables into the global workspace
    if nargout == 1
        r = robot;
    elseif nargout == 0
        assignin('caller', 's6', robot);
        assignin('caller', 'qz', [0 0 0 0 0 0]); % zero angles, arm up
    end
end

author: petercorke

repo: robotics-toolbox-matlab


text:
%PARZEN_MAP Map a dataset on a Parzen densities based classifier
%
% 	F = PARZEN_MAP(A,W)
%
% INPUT
%   A   Dataset
%   W   Trained Parzen classifier mapping (default: PARZENC(A))
%
% OUTPUT
%   F   Mapped dataset
%
% DESCRIPTION
% Maps the dataset A by the Parzen density based classfier W. F*sigm are the
% posterior probabilities. W should be trained by a classifier like PARZENC.
% This routine is called automatically to solve A*W, if W is trained by
% PARZENC.
%
% The global PRMEMORY is read for the maximum size of the internally declared
% matrix, default inf.
%
% SEE ALSO (PRTools Guide)
% MAPPINGS, DATASETS, PARZENC, TESTP

% Copyright: R.P.W. Duin, r.p.w.duin@37steps.com
% Faculty EWI, Delft University of Technology
% P.O. Box 5031, 2600 GA Delft, The Netherlands

% $Id: parzen_map.m,v 1.5 2008/08/18 21:16:26 duin Exp $

function f = parzen_map(b,w)

		% If no mapping is supplied, train one.
	if (nargin < 2)
		w = parzenc(b);
	end

	pars = getdata(w);
	a = pars{1}; 								% Stored training dataset.
	h = pars{2}; 								% Smoothing paramater.

	[m,k,c] = getsize(a); nlab = getnlab(a); p = getprior(a);

	% do we have priors set in the mapping?
	if length(pars)==3
	   p=pars{3};
	end

	% Prepare a matrix with smoothing parameters for each class and feature.

	if (size(h,1) == 1)
		h = repmat(h,c,1);
	end
	if (size(h,2) == 1)
		h = repmat(h,1,k);
	end

	if (any(size(h) ~= [c,k]))
		error('The size of the array with smoothing parameters does not match that of the training set of W.');
	end

	[mt,kt] = size(b);
	if (kt ~= k)
		error('The size of the set A does not match that of the training set of W.');
	end

	[num,n] = prmem(mt,m);
	f = ones(mt,c); 					% Prob. densities for each test sample and class.

	for j = 0:num-1						% Process each chunk of the test set separately.

		if (j == num-1)
			nn = mt - num*n + n;	% Last chunk may have smaller size.
		else
			nn = n;
		end
		range = [j*n+1:j*n+nn];

		% Estimate the class probabilities.

		for i = 1:c

			if islabtype(a,'crisp')
				I = findnlab(a,i); hh = h(i,:);		% Parameters for this class.

				% Calculate squared distances to kernel centers.

				D = +distm(a(I,:)./repmat(hh,length(I),1), ...
				           +b(range,:)./repmat(hh,length(range),1));
				if (length(I) > 0)
					f(range,i) = mean(exp(-D*0.5),1)';			% Apply kernel.
				end
				const = repmat(-log(length(I)),length(I),1);
			else
				hh = h(i,:);
				I = find(a.targets(:,i) > 0); % Avoid objects with zero weight
				v = a.targets(I,i);
				D = distm(+a(I,:)./repmat(hh,length(I),1), ...
                 +b(range,:)./repmat(hh,length(range),1));
				f(range,i) = exp(-D'*0.5) * v / sum(v);
				const = log(v/sum(v));
			end
			% Normalize and multiply by class prior to get a density. Add REALMIN
			% to prevent division-by-zero errors.
			f(range,i) = p(i)*f(range,i)/((sqrt(2*pi).^k)*prod(hh)+realmin);
			if (getout_conv(w) == 2) % take log of density to preserve tails
				J = find(f(range,i) <= 1e-303);
				N = find(f(range,i) >  1e-303);
				f(range(N),i) = log(f(range(N),i));
				[dm,R] = min(D(:,J)); % for zero densities use nearest neighbor only
				%f(range(J),i) = log(p(i)/((sqrt(2*pi).^k)*prod(hh)+realmin)) - dm'*0.5 + const(R);
				f(range(J),i) = log(p(i)) - k*log(sqrt(2*pi)) - sum(log(hh)) - dm'*0.5 + const(R);
				% in case of soft labels this is tricki. We just hope that the
				% weight of the nearest neighbor is sufficiently large
			end
		end
	end
	if (getout_conv(w) == 2) % scale to gain accuracy in the tails
		fmax = max(f,[],2);
		f = f - repmat(fmax,1,c);
		f = exp(f);
	else
		f = f + realmin; % avoid devision by 0 in computing posterios later
  end

  if isdataset(b)
    f = setdata(b,f,getlabels(w));
  end
return

author: marianux

repo: ecg-kit

save_path: github-repos/MATLAB/marianux-ecg-kit


text:
function [ x, w ] = ccc_nested_rule ( n )

%*****************************************************************************80
%
%% CCC_NESTED_RULE computes the nested Clenshaw Curtis Closed rule.
%
%  Discussion:
%
%    Nested version of Clenshaw Curtis Closed rule on [-1,+1].
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    03 February 2011
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer N, the order of the rule.
%
%    Output, real X(N), W(N), the points and weights.
%

%
%  Get N equally spaced points that, in general, include [ 0, 1];
%
  if ( n == 1 )
    x = 0.5;
  elseif ( n == 2 )
    x = [ 0.5, 0.0 ];
  elseif ( n == 3 )
    x = [ 0.5, 0.0, 1.0 ];
  else
    x = vdc_sequence ( n - 2 );
    x(4:n) = x(2:n-2);
    x(2) = 0.0;
    x(3) = 1.0;
  end
%
%  Apply the Chebyshev transformation from [0,1] to [-1,+1].
%
  x = cos ( pi * x );
%
%  Get the weights.
%
  x_min = -1.0;
  x_max = +1.0;

  w = nc_compute ( n, x_min, x_max, x );

  return
end

author: johannesgerer

repo: jburkardt-m


text:
function det = r8pbl_det ( n, mu, a_lu )

%*****************************************************************************80
%
%% R8PBL_DET computes the determinant of a matrix factored by R8PBL_FA.
%
%  Discussion:
%
%    The R8PBL storage format is for a symmetric positive definite band matrix.
%
%    To save storage, only the diagonal and lower triangle of A is stored,
%    in a compact diagonal format that preserves columns.
%
%    The diagonal is stored in row 1 of the array.
%    The first subdiagonal in row 2, columns 1 through MU.
%    The second subdiagonal in row 3, columns 1 through MU-1.
%    The MU-th subdiagonal in row MU+1, columns 1 through 1.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    22 February 2004
%
%  Author:
%
%    MATLAB version by John Burkardt.
%
%  Reference:
%
%    Dongarra, Bunch, Moler, Stewart,
%    LINPACK User's Guide,
%    SIAM, Philadelphia, 1979.
%
%  Parameters:
%
%    Input, integer N, the order of the matrix.
%    N must be positive.
%
%    Input, integer MU, the upper (and lower) bandwidth.
%    MU must be nonnegative, and no greater than N-1.
%
%    Input, real A_LU(MU+1,N), the LU factors from R8PBL_FA.
%
%    Output, real DET, the determinant of the matrix.
%
  det = prod ( a_lu(1,1:n).^2 );

  return
end


text:
classdef DesignVarMonitor_LevelSet_2D < DesignVarMonitor_LevelSet

    properties (Access = protected)
        unfittedType = 'INTERIOR'
        meshIncludeBoxContour = false
    end

end

author: SwanLab

repo: Swan

save_path: github-repos/MATLAB/SwanLab-Swan


text:
function vn = normalize3d(v)
%NORMALIZE3D normalize a 3D vector.
%
%   V2 = normalize3d(V);
%   Returns the normalization of vector V, such that ||V|| = 1. Vector V is
%   given as a row vector.
%
%   When V is a Nx3 array, normalization is performed for each row of the
%   array.
%
%   See also:
%   vectors3d, vecnorm3d

% ------
% Author: David Legland
% e-mail: david.legland@inrae.fr
% Created: 2004-11-29
% Copyright 2004 INRA - TPV URPOI - BIA IMASTE

% deprecation warning
warning('geom3d:deprecated', ...
    '''normalize3d'' is deprecated, use ''normalizeVector3d'' instead');

n = sqrt(v(:,1).*v(:,1) + v(:,2).*v(:,2) + v(:,3).*v(:,3));
vn = v./[n n n];

author: mattools

repo: matGeom

save_path: github-repos/MATLAB/mattools-matGeom


function imagelist_to_sds(imnames, imgdir, mcgdir, ovoutdir, sptextdir, regspimgdir, featdir, refinedoutdir, scorefile,topk)
%%%%%%
%MCG
%%%%%%
fprintf('Computing MCG. Note that this can be parallelized\n');

if(~exist(mcgdir, 'file')) mkdir(mcgdir); end

for i=1:numel(imnames)
    fprintf('MCG : %d/%d\n', i, numel(imnames));
    imname=imnames{i};
    imgfile=fullfile(imgdir, [imname '.jpg']);
    img=imread(imgfile);
    candidates_file=fullfile(mcgdir,[imname '.mat']);
    if(~exist(candidates_file))

        candidates=im2mcg(img, 'accurate');
        save(candidates_file, 'candidates');
    end
end

%%%%%%%%%%%
%Preprocess
%%%%%%%%%%%
fprintf('Preprocessing candidates.\n');
[region_meta_info]=preprocess_mcg_candidates(imnames, mcgdir, [], ovoutdir, sptextdir, regspimgdir, 2000);

%%%%%%%%%%%%%
%Load network
%%%%%%%%%%%%%
model_def_file='prototxts/pinetwork_extract_fc7.prototxt';
model_file='sds_pretrained_models/nets/C';
assert(exist(model_def_file, 'file')>0);
assert(exist(model_file, 'file')>0);
rcnn_model=rcnn_create_model(model_def_file,model_file);
rcnn_model=rcnn_load_model(rcnn_model);

%%%%%%%%%%%%%%%%%
%Extract features
%%%%%%%%%%%%%%%%%
fprintf('Saving features..\n');
save_features(imnames, imgdir, sptextdir, regspimgdir, featdir, rcnn_model);

%%%%%%%%%%%%%%%%%
%Score candidates
%%%%%%%%%%%%%%%%%
fprintf('Scoring using SVMs..\n');
svmfile='sds_pretrained_models/svms/C.mat';
tmp=load(svmfile);
scores=test_svms(tmp.models, imnames,featdir);

%%%%%%%%%%%%%%%%%%
%NMS and pick top
%%%%%%%%%%%%%%%%%%
fprintf('Refining and picking top detections\n');
[chosen, chosenscores]=region_nms(ovoutdir, imnames, scores, region_meta_info, 20);
%keep only topk per category
[topchosen, topscores]=get_top_regions(chosen, chosenscores, region_meta_info.overlaps, topk);
save(scorefile, 'scores', 'topchosen', 'topscores');

%%%%%%%%%%%%%%%%
%Refine
%%%%%%%%%%%%%%%%
tmp=load('sds_pretrained_models/refinement_models.mat');
for i=1:20
    fprintf('Refining for category %d\n', i);
    test_save_refiner(imnames, fullfile(refinedoutdir, int2str(i)), topchosen{i}, region_meta_info, featdir, sptextdir, regspimgdir, tmp.refinement_models{i},[10 10] );
end


text:
function matRad_compileMCsquareSparseReader(dest,sourceFolder)
% Compiles the sparse mcsquare reader as mex interface
% for the current platform
%
% call
%   matRad_compileMCsquareSparseReader()
%   matRad_compileMCsquareSparseReader(dest)
%   matRad_compileMCsquareSparseReader(dest,sourceFolder)
%
% input:
%   dest:           (optional) destination for mex file. Default: location of this
%                   file
%   sourceFolder:   (optional) path to folder. Default: location of this
%                   file
%
% References
%
%   https://aapm.onlinelibrary.wiley.com/doi/abs/10.1118/1.4943377
%   http://www.openmcsquare.org/
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Copyright 2020 the matRad development team.
%
% This file is part of the matRad project. It is subject to the license
% terms in the LICENSE file found in the top-level directory of this
% distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part
% of the matRad project, including this file, may be copied, modified,
% propagated, or distributed except according to the terms contained in the
% LICENSE file.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

matRad_cfg = MatRad_Config.instance();

if nargin < 1
    dest = fileparts(mfilename('fullpath'));
end

if nargin < 2
    sourceFolder = fileparts(mfilename('fullpath'));
end

if exist ('OCTAVE_VERSION', 'builtin')
    ccName = evalc('mkoctfile -p CXX');
else
    myCCompiler = mex.getCompilerConfigurations('C','Selected');
    ccName = myCCompiler.ShortName;
end

%These settings have only been tested for MSVC and g++. You may need to adapt for other compilers
if ~isempty(strfind(ccName,'MSVC')) %Not use contains(...) because of octave
    flags{1,1} = 'COMPFLAGS';
    flags{1,2} = '/O2';
else
    flags{1,1} = 'CXXFLAGS';
    flags{1,2} = '-std=c++11 -O2 -fPIC';
end

flagstring = '';

%For Octave, the flags will be set in the environment, while they
%will be parsed as string arguments in MATLAB
for flag = 1:size(flags,1)
    if exist ('OCTAVE_VERSION', 'builtin')
        setenv(flags{flag,1},flags{flag,2});
    else
        flagstring = [flagstring flags{flag,1} '="' flags{flag,2} '" '];
    end
end

mexCall = ['mex -largeArrayDims ' flagstring ' ' sourceFolder filesep 'matRad_sparseBeamletsReaderMCsquare.cpp'];

matRad_cfg.dispDebug('Compiler call: %s\n',mexCall);

currDir = pwd;
cd(dest);
eval(mexCall);
cd(currDir);

end

repo: matRad


text:
function varargout = VScope(varargin)
% VSCOPE M-file for VScope.fig
%      VSCOPE, by itself, creates a new VSCOPE or raises the existing
%      singleton*.
%
%      H = VSCOPE returns the handle to a new VSCOPE or the handle to
%      the existing singleton*.
%
%      VSCOPE('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in VSCOPE.M with the given input arguments.
%
%      VSCOPE('Property','Value',...) creates a new VSCOPE or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before VScope_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to VScope_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help VScope

% Last Modified by GUIDE v2.5 15-Jan-2009 11:33:57

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @VScope_OpeningFcn, ...
                   'gui_OutputFcn',  @VScope_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT

% --- Executes just before VScope is made visible.
function VScope_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to VScope (see VARARGIN)

% Choose default command line output for VScope
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes VScope wait for user response (see UIRESUME)
% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = VScope_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;

%%%%pushbutton3_Callback(handles.pushbutton3,[],handles)

% set(handles.text2,'string','BISMILLAH AR REHMAN AR RAHIM')
% pause(2)
% set(handles.text2,'string','ALLAH AKBAR')
% pause(2)
% set(handles.text2,'string','Welcome to Virtual Oscilloscope!!')
% pause(2)
%
% s=serial('com1');
% fopen(s);
% fprintf(s,'*idn?');
% out=fscanf(s);
% out=strcat('Oscilloscope ID=  ',out)
% fclose(s);
% set(handles.text2,out)
% %fclose(s);
% pause(3)
% set(handles.text2,'string',' ')

%---------------------------------------------------------
set(handles.popupmenu11,'enable','off')
set(handles.popupmenu6,'enable','off')
set(handles.popupmenu5,'enable','off')
set(handles.popupmenu4,'enable','off')
set(handles.popupmenu9,'enable','off')
set(handles.popupmenu10,'enable','off')
set(handles.togglebutton2,'enable','off')
set(handles.pushbutton6,'enable','off')
set(handles.popupmenu3,'enable','off')
set(handles.popupmenu2,'enable','off')

set(handles.radiobutton4,'enable','on')
set(handles.radiobutton5,'enable','on')
set(handles.radiobutton6,'enable','on')
set(handles.radiobutton7,'enable','on')
set(handles.slider1,'enable','on')
set(handles.slider2,'enable','on')

% % % % % function latch2(off)
% % % % % set(off,'value',0)
% % % % %
% % % % % % --- Executes on button press in radiobutton8.
% % % % % function radiobutton8_Callback(hObject, eventdata, handles)
% % % % % % hObject    handle to radiobutton8 (see GCBO)
% % % % % % eventdata  reserved - to be defined in a future version of MATLAB
% % % % % % handles    structure with handles and user data (see GUIDATA)
% % % % %
% % % % % % Hint: get(hObject,'Value') returns toggle state of radiobutton8
% % % % %
% % % % % off = [handles.radiobutton9]
% % % % % latch2(off)
% % % % %
% % % % % set(handles.popupmenu11,'enable','off')
% % % % % set(handles.popupmenu6,'enable','off')
% % % % % set(handles.popupmenu5,'enable','off')
% % % % % set(handles.popupmenu4,'enable','off')
% % % % % set(handles.popupmenu9,'enable','off')
% % % % % set(handles.popupmenu10,'enable','off')
% % % % % set(handles.togglebutton2,'enable','off')
% % % % % set(handles.pushbutton6,'enable','off')
% % % % % set(handles.popupmenu3,'enable','off')
% % % % % set(handles.popupmenu2,'enable','off')
% % % % %
% % % % % set(handles.radiobutton4,'enable','on')
% % % % % set(handles.radiobutton5,'enable','on')
% % % % % set(handles.radiobutton6,'enable','on')
% % % % % set(handles.radiobutton7,'enable','on')
% % % % % set(handles.slider1,'enable','on')
% % % % % set(handles.slider2,'enable','on')
% % % % %
% % % % %
% % % % %
% % % % % % --- Executes on button press in radiobutton9.
% % % % % function radiobutton9_Callback(hObject, eventdata, handles)
% % % % % % hObject    handle to radiobutton9 (see GCBO)
% % % % % % eventdata  reserved - to be defined in a future version of MATLAB
% % % % % % handles    structure with handles and user data (see GUIDATA)
% % % % %
% % % % % % Hint: get(hObject,'Value') returns toggle state of radiobutton9
% % % % %
% % % % % off = [handles.radiobutton8]
% % % % % latch2(off)
% % % % %
% % % % % set(handles.radiobutton4,'enable','off')
% % % % % set(handles.radiobutton5,'enable','off')
% % % % % set(handles.radiobutton6,'enable','off')
% % % % % set(handles.radiobutton7,'enable','off')
% % % % % set(handles.slider1,'enable','off')
% % % % % set(handles.slider2,'enable','off')
% % % % %
% % % % % set(handles.popupmenu11,'enable','on')
% % % % % set(handles.popupmenu6,'enable','on')
% % % % % set(handles.popupmenu5,'enable','on')
% % % % % set(handles.popupmenu4,'enable','on')
% % % % % set(handles.popupmenu9,'enable','on')
% % % % % set(handles.popupmenu10,'enable','on')
% % % % % set(handles.togglebutton2,'enable','on')
% % % % % set(handles.pushbutton6,'enable','on')
% % % % % set(handles.popupmenu3,'enable','on')
% % % % % set(handles.popupmenu2,'enable','on')

%----------------------------------------------------------------------
function latch(off)
set(off,'Value',0)

% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject    handle to slider1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

freq=get(handles.slider1,'value');
set(handles.text3,'string',freq);

save freq freq

% Latching On CHECK BOXES
%*************************************************************************

% if (get(handles.checkbox1,'value')) == get(handles.checkbox1,'Max')
%    %set(handles.checkbox2,'value',0)
%    %set(handles.checkbox3,'value',0)
%   t=-10:0.1:10;
%   y=sin(t*val1)
%   axis(handles.axes1)
%   plot(t,y)
%   %hold on
% elseif (get(handles.checkbox2,'value')) == get(handles.checkbox2,'Max')
%     %set(handles.checkbox1,'value',0)
%     %set(handles.checkbox3,'value',0)
%    t1=-10:0.1:10;
%    y1=cos(t1*val1)
%    axis(handles.axes1)
%    plot(t1,y1,'r')
%    %hold on
% elseif (get(handles.checkbox3,'value')) == get(handles.checkbox3,'Max')
%     %set(handles.checkbox1,'value',0)
%     %set(handles.checkbox2,'value',0)
%    t2=-10:0.1:10;
%    y2=tan(t2*val1)
%    axis(handles.axes1)
%    plot(t2,y2,'k')
%    %hold on
% else axis(handles.axes1)
%    cla
% end
%**************************************************************************

% Latching On Radio Buttons SLIDER 1
%**************************************************************************
if (get(handles.radiobutton4,'value')) == get(handles.radiobutton4,'Max')

   a=get(handles.slider2,'value');

   t=-8:0.001:8;
   y=a*sin(2*pi*freq*t);

   axis(handles.axes1);
   plot(t,y);
   axis([-8 8 -10 10]);
elseif (get(handles.radiobutton5,'value')) == get(handles.radiobutton5,'Max')

   a=get(handles.slider2,'value');

   t1=-8:0.001:8;
   y1=a*cos(2*pi*freq*t1);
   %axis([-2 2 -5 5])
   axis(handles.axes1);
   plot(t1,y1,'r');
   axis([-8 8 -10 10]);
elseif (get(handles.radiobutton6,'value')) == get(handles.radiobutton6,'Max')

   a=get(handles.slider2,'value');

   t2=-8:0.001:8;
   y2=a*tan(2*pi*freq*t2);
   %axis([-2 2 -5 5])
   axis(handles.axes1);
   plot(t2,y2,'k');
   axis([-8 8 -10 10]);
elseif (get(handles.radiobutton7,'value')) == get(handles.radiobutton7,'Max')

    a=get(handles.slider2,'value');
    t3=-8:0.001:8;
    y3=a*square(2*pi*freq*t3);
    axis(handles.axes1);
    plot(t3,y3,'m');
    axis([-8 8 -10 10]);
else axis(handles.axes1)
    cla
end

%**************************************************************************

% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end

% --- Executes on slider movement.
function slider2_Callback(hObject, eventdata, handles)
% hObject    handle to slider2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

%Latching On Radio Buttons Only* SLIDER 2
%**************************************************************************
a=get(handles.slider2,'value');
set(handles.text4,'string',a);

save a a

if (get(handles.radiobutton4,'value')) == get(handles.radiobutton4,'Max')

   freq=get(handles.slider1,'value');

   t=-8:0.001:8;
   y=a*sin(2*pi*freq*t);
   %axis([-2 2 -5 5])
   axis(handles.axes1);
   plot(t,y);
   axis([-8 8 -10 10]);

elseif (get(handles.radiobutton5,'value')) == get(handles.radiobutton5,'Max')

   freq=get(handles.slider1,'value');

   t1=-8:0.001:8;
   y1=a*cos(2*pi*freq*t1);
   %axis([-2 2 -5 5])
   axis(handles.axes1);
   plot(t1,y1,'r');
   axis([-8 8 -10 10]);
elseif (get(handles.radiobutton6,'value')) == get(handles.radiobutton6,'Max')

   freq=get(handles.slider1,'value');

   t2=-8:0.001:8;
   y2=a*tan(2*pi*freq*t2);
   %axis([-2 2 -5 5])
   axis(handles.axes1);
   plot(t2,y2,'k');
   axis([-8 8 -10 10]);
elseif (get(handles.radiobutton7,'value')) == get(handles.radiobutton7,'Max')
    freq=get(handles.slider1,'value');

    t3=-8:0.001:8;
    y3=a*square(2*pi*freq*t3);
    axis(handles.axes1);
    plot(t3,y3,'m');
    axis([-8 8 -10 10]);
else axis(handles.axes1)
    cla
end

%**************************************************************************

% --- Executes during object creation, after setting all properties.
function slider2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end

%Latching On Check Boxes
%**************************************************************************

% % --- Executes on button press in checkbox1.
% function checkbox1_Callback(h, eventdata, handles, varargin)
% % hObject    handle to checkbox1 (see GCBO)
% % eventdata  reserved - to be defined in a future version of MATLAB
% % handles    structure with handles and user data (see GUIDATA)
%
% % Hint: get(hObject,'Value') returns toggle state of checkbox1
%
% %function checkbox1_Callback(h,eventdata,handles,varargin)
% if (get(handles.checkbox1,'value')) == get(handles.checkbox1,'Max')
%    t=-10:0.1:10;
%    y=sin(t*val1)
%    axis(handles.axes1)
%    plot(t,y)
% else axis(handles.axes1)
%      cla
%  end

% --- Executes on button press in checkbox2.
% function checkbox2_Callback(h, eventdata, handles, varargin)
% % hObject    handle to checkbox2 (see GCBO)
% % eventdata  reserved - to be defined in a future version of MATLAB
% % handles    structure with handles and user data (see GUIDATA)
%
% % Hint: get(hObject,'Value') returns toggle state of checkbox2
% if (get(handles.checkbox2,'value')) == get(handles.checkbox2,'Max')
%     t1=-10:0.1:10;
%     y1=cos(t1*val1)
%     axis(handles.axes1)
%     plot(t1,y1,'r')
% else axis(handles.axes1)
%     cla
% end
%
%
% % --- Executes on button press in checkbox3.
% function checkbox3_Callback(h, eventdata, handles, varargin)
% % hObject    handle to checkbox3 (see GCBO)
% % eventdata  reserved - to be defined in a future version of MATLAB
% % handles    structure with handles and user data (see GUIDATA)
%
% % Hint: get(hObject,'Value') returns toggle state of checkbox3
%
% if (get(handles.checkbox3,'value')) == get(handles.checkbox3,'Max')
%     t2=-10:0.1:10;
%     y2=tan(t2*val1)
%     axis(handles.axes1)
%     plot(t2,y2,'k')
% else axis(handles.axes1)
%     cla
% end

%**************************************************************************

%Latching On Radio Buttons
%**************************************************************************

% --- Executes on button press in radiobutton4.
function varargout = radiobutton4_Callback(h, eventdata, handles, varargin)
% hObject    handle to radiobutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton4

off = [handles.radiobutton5,handles.radiobutton6,handles.radiobutton7];
latch(off)
if (get(handles.radiobutton4,'value')) == get(handles.radiobutton4,'Max')
    idd='1';

   freq=get(handles.slider1,'value');

   a=get(handles.slider2,'value');

   t=-8:0.001:8;
   y=a*sin(2*pi*freq*t);

   axis(handles.axes1);
   plot(t,y);
   %grid minor;
   axis([-8 8 -10 10]);

% % %    save valuerb4 a freq t y

else axis(handles.axes1)
     cla
     idd='0';
end

save idd idd;

% --- Executes on button press in radiobutton5.
function varargout = radiobutton5_Callback(h, eventdata, handles, varargin)
% hObject    handle to radiobutton5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton5
off = [handles.radiobutton4,handles.radiobutton6,handles.radiobutton7];
latch(off);
if (get(handles.radiobutton5,'value')) == get(handles.radiobutton5,'Max')
    idd='2';
   freq=get(handles.slider1,'value');

   a=get(handles.slider2,'value');

   t1=-8:0.001:8;
   y1=a*cos(2*pi*freq*t1);

   axis(handles.axes1);
   plot(t1,y1,'r');
   %grid minor;
   axis([-8 8 -10 10]);

% % %    save valuerb5 a freq t1 y1

else axis(handles.axes1)
     cla
     idd='0';
 end
save idd idd;
% --- Executes on button press in radiobutton6.
function varargout = radiobutton6_Callback(h, eventdata, handles, varargin)
% hObject    handle to radiobutton6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton6
off = [handles.radiobutton4,handles.radiobutton5,handles.radiobutton7];
latch(off);
if (get(handles.radiobutton6,'value')) == get(handles.radiobutton6,'Max')
    idd='3';
   freq=get(handles.slider1,'value');

   a=get(handles.slider2,'value');

   t2=-8:0.001:8;
   y2=a*tan(2*pi*freq*t2);

   axis(handles.axes1);
   plot(t2,y2,'k');
   %grid minor;
   axis([-8 8 -10 10]);
% % %    save valuerb6 a freq t2 y2

else axis(handles.axes1)
     cla
     idd='0';
end

save idd idd;
 %*************************************************************************

% --- Executes on button press in radiobutton7.
function varargout = radiobutton7_Callback(h, eventdata, handles, varargin)
% hObject    handle to radiobutton7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton7

off = [handles.radiobutton4,handles.radiobutton5,handles.radiobutton6];
latch(off);
if (get(handles.radiobutton7,'value')) == get(handles.radiobutton7,'Max')
    idd='4';
    freq=get(handles.slider1,'value');
    a=get(handles.slider2,'value');
    t3=-8:0.001:8;
    y3=a*square(2*pi*freq*t3);
    axis(handles.axes1);
    plot(t3,y3,'m');
    %grid minor;
    axis([-8 8 -10 10]);
% % %     save valuerb7 a freq t3 y3

else axis(handles.axes1)
    cla
    idd='0'
end

save idd idd;

% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

sure

% --- Executes on button press in togglebutton2.
function varargout = togglebutton2_Callback(h, eventdata, handles, varargin)
% hObject    handle to togglebutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of togglebutton2

button_state=get(handles.togglebutton2,'value');

if button_state == get(handles.togglebutton2,'Max')
    s=serial('com1');
    s.inputbuffersize=16384;
    s.outputbuffersize=16384;
    handles.data=s;
    fopen(s);
    x1=s.status;
    x1=strcat('COM1= ',x1);
    set(handles.text2,'string', x1);
    pause(1);
    set(handles.text2,'string',' ');
    guidata(handles.togglebutton2,handles);
elseif button_state == get(handles.togglebutton2,'Min')
    s=handles.data;
    fclose(s);
    x1=s.status;
    x1=strcat('COM1=  ', x1);
    set(handles.text2,'string', x1);
    pause(1);
    set(handles.text2,'string',' ');
    clear
end

% % % % % % % % % % --- Executes on button press in pushbutton3.
% % % % % % % % % function varargout = pushbutton3_Callback(h, eventdata, handles, varargin)
% % % % % % % % % % hObject    handle to pushbutton3 (see GCBO)
% % % % % % % % % % eventdata  reserved - to be defined in a future version of MATLAB
% % % % % % % % % % handles    structure with handles and user data (see GUIDATA)
% % % % % % % % %
% % % % % % % % % s=serial('com1');
% % % % % % % % % nxg=s.status;
% % % % % % % % % if nxg == 'open'
% % % % % % % % %     set(handles.text2,'string','COM1 already open')
% % % % % % % % % else
% % % % % % % % %     s.inputbuffersize=16384;
% % % % % % % % %     s.outputbuffersize=16384;
% % % % % % % % %     handles.data=s;
% % % % % % % % %     fopen(s);
% % % % % % % % %     x1=s.status;
% % % % % % % % %     x1=strcat('COM1= ',x1);
% % % % % % % % %     set(handles.text2,'string', x1)
% % % % % % % % %     pause(1)
% % % % % % % % %     set(handles.text2,'string',' ')
% % % % % % % % %     guidata(handles.pushbutton3,handles)
% % % % % % % % % end
% % % % % % % % %
% % % % % % % % %
% % % % % % % % %
% % % % % % % % %
% % % % % % % % % % --- Executes on button press in pushbutton4.
% % % % % % % % % function varargout = pushbutton4_Callback(h, eventdata, handles, varargin)
% % % % % % % % % % hObject    handle to pushbutton4 (see GCBO)
% % % % % % % % % % eventdata  reserved - to be defined in a future version of MATLAB
% % % % % % % % % % handles    structure with handles and user data (see GUIDATA)
% % % % % % % % %
% % % % % % % % % % % s=serial('com1');
% % % % % % % % % % % fopen(s);
% % % % % % % % % % % fclose(s)
% % % % % % % % % % % x1=s.status;
% % % % % % % % % % % x1=strcat('COM1=  ', x1)
% % % % % % % % % % % set(handles.text2,'string', x1)
% % % % % % % % % % % pause(5)
% % % % % % % % % % % set(handles.text2,'string',' ')
% % % % % % % % %
% % % % % % % % %
% % % % % % % % % s=handles.data;
% % % % % % % % % fclose(s);
% % % % % % % % % x1=s.status;
% % % % % % % % % x1=strcat('COM1=  ', x1)
% % % % % % % % % set(handles.text2,'string', x1)
% % % % % % % % % pause(1)
% % % % % % % % % set(handles.text2,'string',' ')
% % % % % % % % % clear

% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

sure2

% --- Executes on button press in pushbutton6.
function varargout = pushbutton6_Callback(h, eventdata, handles, varargin)
% hObject    handle to pushbutton6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA

s=handles.data;
fclose(s);
nn=s.status;
nn=strcat('COM1= ',nn)
set(handles.text2,'string',nn)
clear

waveformm

% --- Executes on selection change in popupmenu2.
function varargout = popupmenu2_Callback(h, eventdata, handles, varargin)
% hObject    handle to popupmenu2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu2 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu2
s=handles.data;
wadt=get(handles.popupmenu2,'value');
switch wadt
    case 1
        set(handles.text2,'string',' ');
    case 2
        fprintf(s,':acquire1:memory?');
        out1=fscanf(s);
        set(handles.text2,'string',out1);

    case 3
        fprintf(s,':acquire1:point');
        out2=fscanf(s);
%       out2=hex2dec(out2);
        out2=num2str(out2);
        set(handles.text2,'string',out2);
end

% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

% --- Executes on selection change in popupmenu3.
function popupmenu3_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu3 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu3

s=handles.data;
otcm=get(handles.popupmenu3,'value');
switch otcm
    case 1
        set(handles.text2,'string',' ');
    case 2
        fprintf(s,'*idn?');
        out1=fscanf(s);
        set(handles.text2,'string',out1);
    case 3
        fprintf(s,'*lrn?');
        out2=fscanf(s);
        set(handles.text2,'string',out2);
    case 4
        fprintf(s,'*wai?');
        out3=fscanf(s);
        set(handles.text2,'string',out3);
end

% --- Executes during object creation, after setting all properties.
function popupmenu3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

% --- Executes on selection change in popupmenu4.
function popupmenu4_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu4 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu4

s=handles.data;
br=get(handles.popupmenu4,'value');
switch br
    case 1
        s.baudrate=0;
        br1=s.baudrate;
        br1=num2str(br1);
        br1=strcat('BaudRate= ',br1);
        set(handles.text2,'string',br1);
    case 2
        s.baudrate=2400;
        br2=s.baudrate;
        br2=num2str(br2);
        br2=strcat('BaudRate= ',br2);
        set(handles.text2,'string',br2);

    case 3
        s.baudrate=4800;
        br3=s.baudrate;
        br3=num2str(br3);
        br3=strcat('BaudRate= ',br3);
        set(handles.text2,'string',br3);
    case 4
        s.baudrate=9600;
        br4=s.baudrate;
        br4=num2str(br4);
        br4=strcat('BaudRate= ',br4);
        set(handles.text2,'string',br4);
    case 5
        s.baudrate=19200;
        br5=s.baudrate;
        br5=num2str(br5);
        br5=strcat('BaudRate= ',br5);
        set(handles.text2,'string',br5);
    case 6
        s.baudrate=38400;
        br6=s.baudrate;
        br6=num2str(br6);
        br6=strcat('BaudRate= ',br6);
        set(handles.text2,'string',br6);
end

% --- Executes during object creation, after setting all properties.
function popupmenu4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

% --- Executes on selection change in popupmenu5.
function popupmenu5_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu5 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu5

s=handles.data;
sb=get(handles.popupmenu5,'value');
switch sb
    case 1
        s.stopbit=1;
        sb1=s.stopbit;
        sb1=num2str(sb1);
        sb1=strcat('StopBit= ',sb1);
        set(handles.text2,'string',sb1);
    case 2
        s.stopbit=2;
        sb2=s.stopbit;
        sb2=num2str(sb2);
        sb2=strcat('StopBit= ',sb2);
        set(handles.text2,'string',sb2);
end

% --- Executes during object creation, after setting all properties.
function popupmenu5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

% --- Executes on selection change in popupmenu6.
function popupmenu6_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu6 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu6

s=handles.data;
par=get(handles.popupmenu6,'value');
switch par
    case 1
        s.parity='none';
        sta1=s.parity;
        sta1=strcat('Parity= ',sta1);
        set(handles.text2,'string',sta1);
    case 2
        s.parity='even';
        sta2=s.parity;
        sta2=strcat('Parity= ',sta2);
        set(handles.text2,'string',sta2);
    case 3
        s.parity='odd';
        sta3=s.parity;
        sta3=strcat('Parity= ',sta3);
        set(handles.text2,'string',sta3);
end

% --- Executes during object creation, after setting all properties.
function popupmenu6_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

% --- Executes on selection change in popupmenu9.
function popupmenu9_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu9 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu9

s=handles.data;
wam=get(handles.popupmenu9,'value');
switch wam
    case 1
        fprintf(s,':acquire:mode0');
        fprintf(s,':acquire:mode?');
        out1=fscanf(s);
        out1=strcat('WaveformAcquisitionMode= ',out1);
        set(handles.text2,'string',out1);

    case 2
        fprintf(s,':acquire:mode1');
        fprintf(s,':acquire:mode?');
        out2=fscanf(s);
        out2=strcat('WaveformAcquisitionMode= ',out2);
        set(handles.text2,'string',out2);

    case 3
        fprintf(s,':acquire:mode2');
        fprintf(s,':acquire:mode?');
        out3=fscanf(s);
        out3=strcat('WaveformAcquisitionMode= ',out3);
        set(handles.text2,'string',out3);
end

% --- Executes during object creation, after setting all properties.
function popupmenu9_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

% --- Executes on selection change in popupmenu10.
function popupmenu10_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu10 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu10

s=handles.data;
rl=get(handles.popupmenu10,'value');
switch rl
    case 1
        fprintf(s,':acquire:lenght0');
        fprintf(s,':acquire:length?');
        out1=fscanf(s);
        out1=strcat('RecordLength= ',out1);
        set(handles.text2,'string',out1);

    case 2
        fprintf(s,':acquire:lenght1');
        fprintf(s,':acquire:length?');
        out2=fscanf(s);
        out2=strcat('RecordLength= ',out2);
        set(handles.text2,'string',out2);

    case 3
        fprintf(s,':acquire:lenght2');
        fprintf(s,':acquire:length?');
        out3=fscanf(s);
        out3=strcat('RecordLength= ',out3);
        set(handles.text2,'string',out3);

    case 4
        fprintf(s,':acquire:lenght3');
        fprintf(s,':acquire:length?');
        out4=fscanf(s);
        out4=strcat('RecordLength= ',out4);
        set(handles.text2,'string',out4);

    case 5
        fprintf(s,':acquire:lenght4');
        fprintf(s,':acquire:length?');
        out5=fscanf(s);
        out5=strcat('RecordLength= ',out5);
        set(handles.text2,'string',out5);

    case 6
        fprintf(s,':acquire:lenght5');
        fprintf(s,':acquire:length?');
        out6=fscanf(s);
        out6=strcat('RecordLength= ',out6);
        set(handles.text2,'string',out6);

    case 7
        fprintf(s,':acquire:lenght6');
        fprintf(s,':acquire:length?');
        out7=fscanf(s);
        out7=strcat('RecordLength= ',out7);
        set(handles.text2,'string',out7);

    case 8
        fprintf(s,':acquire:lenght7');
        fprintf(s,':acquire:length?');
        out8=fscanf(s);
        out8=strcat('RecordLength= ',out8);
        set(handles.text2,'string',out8);
end

% --- Executes during object creation, after setting all properties.
function popupmenu10_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

% --- Executes on selection change in popupmenu11.
function popupmenu11_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu11 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu11

s=handles.data;
an=get(handles.popupmenu11,'value');
switch an
    case 1
        fprintf(s,':acquire:average1');
        fprintf(s,':acquire:average?');
        out1=fscanf(s);
        out1=strcat('AverageNumber= ',out1);
        set(handles.text2,'string',out1);

    case 2
        fprintf(s,':acquire:average2');
        fprintf(s,':acquire:average?');
        out2=fscanf(s);
        out2=strcat('AverageNumber= ',out2);
        set(handles.text2,'string',out2);

    case 3
        fprintf(s,':acquire:average3');
        fprintf(s,':acquire:average?');
        out3=fscanf(s);
        out3=strcat('AverageNumber= ',out3);
        set(handles.text2,'string',out3);

    case 4
        fprintf(s,':acquire:average4');
        fprintf(s,':acquire:average?');
        out4=fscanf(s);
        out4=strcat('AverageNumber= ',out4);
        set(handles.text2,'string',out4);

    case 5
        fprintf(s,':acquire:average5');
        fprintf(s,':acquire:average?');
        out5=fscanf(s);
        out5=strcat('AverageNumber= ',out5);
        set(handles.text2,'string',out5);

    case 6
        fprintf(s,':acquire:average6');
        fprintf(s,':acquire:average?');
        out6=fscanf(s);
        out6=strcat('AverageNumber= ',out6);
        set(handles.text2,'string',out6);

    case 7
        fprintf(s,':acquire:average7');
        fprintf(s,':acquire:average?');
        out7=fscanf(s);
        out7=strcat('AverageNumber= ',out7);
        set(handles.text2,'string',out7);

    case 8
        fprintf(s,':acquire:average8');
        fprintf(s,':acquire:average?');
        out8=fscanf(s);
        out8=strcat('AverageNumber= ',out8);
        set(handles.text2,'string',out8);

end

% --- Executes during object creation, after setting all properties.
function popupmenu11_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

% --------------------------------------------------------------------
function Untitled_3_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

sure2

% --------------------------------------------------------------------
function Untitled_4_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

open heelp.txt

% --------------------------------------------------------------------
function Untitled_1_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------
function Untitled_2_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------
function Untitled_15_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_15 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------
function Untitled_16_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_16 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------
function Untitled_17_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_17 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------
function Untitled_18_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_18 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------
function Untitled_19_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_19 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------
function Untitled_20_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_20 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------
function Untitled_13_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_13 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------
function Untitled_14_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_14 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------
function Untitled_7_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

[F] = uigetfile('*.fig','Select any .fig file');
open(F);

% --------------------------------------------------------------------
function Untitled_11_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

sure

% --------------------------------------------------------------------
function Untitled_5_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------
function Untitled_9_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------
function Untitled_12_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------
function Untitled_8_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------
function Untitled_21_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_21 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
fprintf(s,':acquire:average1')
fprintf(s,':acquire:average?')
out1=fscanf(s);
out1=strcat('AverageNumber= ',out1)
set(handles.text2,'string',out1)

% --------------------------------------------------------------------
function Untitled_22_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_22 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
fprintf(s,':acquire:average2')
fprintf(s,':acquire:average?')
out2=fscanf(s);
out2=strcat('AverageNumber= ',out2)
set(handles.text2,'string',out2)

% --------------------------------------------------------------------
function Untitled_23_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_23 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
fprintf(s,':acquire:average3')
fprintf(s,':acquire:average?')
out3=fscanf(s);
out3=strcat('AverageNumber= ',out3)
set(handles.text2,'string',out3)

% --------------------------------------------------------------------
function Untitled_24_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_24 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
fprintf(s,':acquire:average4')
fprintf(s,':acquire:average?')
out4=fscanf(s);
out4=strcat('AverageNumber= ',out4)
set(handles.text2,'string',out4)

% --------------------------------------------------------------------
function Untitled_25_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_25 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
fprintf(s,':acquire:average5')
fprintf(s,':acquire:average?')
out5=fscanf(s);
out5=strcat('AverageNumber= ',out5)
set(handles.text2,'string',out5)

% --------------------------------------------------------------------
function Untitled_26_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_26 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
fprintf(s,':acquire:average6')
fprintf(s,':acquire:average?')
out6=fscanf(s);
out6=strcat('AverageNumber= ',out6)
set(handles.text2,'string',out6)

% --------------------------------------------------------------------
function Untitled_27_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_27 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
fprintf(s,':acquire:average7')
fprintf(s,':acquire:average?')
out7=fscanf(s);
out7=strcat('AverageNumber= ',out7)
set(handles.text2,'string',out7)

% --------------------------------------------------------------------
function Untitled_28_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_28 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
fprintf(s,':acquire:average8')
fprintf(s,':acquire:average?')
out8=fscanf(s);
out8=strcat('AverageNumber= ',out8)
set(handles.text2,'string',out8)

% --------------------------------------------------------------------
function Untitled_29_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_29 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
s.parity='none';
sta1=s.parity;
sta1=strcat('Parity= ',sta1)
set(handles.text2,'string',sta1)

% --------------------------------------------------------------------
function Untitled_30_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_30 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
s.parity='even';
sta2=s.parity;
sta2=strcat('Parity= ',sta2)
set(handles.text2,'string',sta2)
% --------------------------------------------------------------------
function Untitled_31_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_31 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
s.parity='odd';
sta3=s.parity;
sta3=strcat('Parity= ',sta3)
set(handles.text2,'string',sta3)

% --------------------------------------------------------------------
function Untitled_32_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_32 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
s.stopbit=1;
sb1=s.stopbit;
sb1=num2str(sb1);
sb1=strcat('StopBit= ',sb1)
set(handles.text2,'string',sb1)

% --------------------------------------------------------------------
function Untitled_33_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_33 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
s.stopbit=2;
sb2=s.stopbit;
sb2=num2str(sb2);
sb2=strcat('StopBit= ',sb2)
set(handles.text2,'string',sb2)

% --------------------------------------------------------------------
function Untitled_34_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_34 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
s.baudrate=0;
        br1=s.baudrate;
        br1=num2str(br1);
        br1=strcat('BaudRate= ',br1)
        set(handles.text2,'string',br1)

% --------------------------------------------------------------------
function Untitled_35_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_35 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
s=handles.data;
s.baudrate=2400;
        br2=s.baudrate;
        br2=num2str(br2);
        br2=strcat('BaudRate= ',br2)
        set(handles.text2,'string',br2)

% --------------------------------------------------------------------
function Untitled_36_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_36 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
s=handles.data;
s.baudrate=4800;
        br3=s.baudrate;
        br3=num2str(br3);
        br3=strcat('BaudRate= ',br3)
        set(handles.text2,'string',br3)
% --------------------------------------------------------------------
function Untitled_37_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_37 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
s=handles.data;
s.baudrate=9600;
        br4=s.baudrate;
        br4=num2str(br4);
        br4=strcat('BaudRate= ',br4)
        set(handles.text2,'string',br4)

% --------------------------------------------------------------------
function Untitled_38_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_38 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
        s.baudrate=19200;
        br5=s.baudrate;
        br5=num2str(br5);
        br5=strcat('BaudRate= ',br5)
        set(handles.text2,'string',br5)
% --------------------------------------------------------------------
function Untitled_39_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_39 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
        s.baudrate=38400;
        br6=s.baudrate;
        br6=num2str(br6);
        br6=strcat('BaudRate= ',br6)
        set(handles.text2,'string',br6)
% --------------------------------------------------------------------
function Untitled_40_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_40 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
s=handles.data;
fprintf(s,':acquire:mode0')
        fprintf(s,':acquire:mode?')
        out1=fscanf(s);
        out1=strcat('WaveformAcquisitionMode= ',out1)
        set(handles.text2,'string',out1)

% --------------------------------------------------------------------
function Untitled_41_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_41 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
        fprintf(s,':acquire:mode1')
        fprintf(s,':acquire:mode?')
        out2=fscanf(s);
        out2=strcat('WaveformAcquisitionMode= ',out2)
        set(handles.text2,'string',out2)
% --------------------------------------------------------------------
function Untitled_42_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_42 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
        fprintf(s,':acquire:mode2')
        fprintf(s,':acquire:mode?')
        out3=fscanf(s);
        out3=strcat('WaveformAcquisitionMode= ',out3)
        set(handles.text2,'string',out3)
% --------------------------------------------------------------------
function Untitled_43_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_43 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

fprintf(s,':acquire:lenght0')
        fprintf(s,':acquire:length?')
        out1=fscanf(s);
        out1=strcat('RecordLength= ',out1)
        set(handles.text2,'string',out1)

% --------------------------------------------------------------------
function Untitled_44_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_44 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
        fprintf(s,':acquire:lenght1')
        fprintf(s,':acquire:length?')
        out2=fscanf(s);
        out2=strcat('RecordLength= ',out2)
        set(handles.text2,'string',out2)
% --------------------------------------------------------------------
function Untitled_45_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_45 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
        fprintf(s,':acquire:lenght2')
        fprintf(s,':acquire:length?')
        out3=fscanf(s);
        out3=strcat('RecordLength= ',out3)
        set(handles.text2,'string',out3)
% --------------------------------------------------------------------
function Untitled_46_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_46 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
        fprintf(s,':acquire:lenght3')
        fprintf(s,':acquire:length?')
        out4=fscanf(s);
        out4=strcat('RecordLength= ',out4)
        set(handles.text2,'string',out4)
% --------------------------------------------------------------------
function Untitled_47_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_47 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
        fprintf(s,':acquire:lenght4')
        fprintf(s,':acquire:length?')
        out5=fscanf(s);
        out5=strcat('RecordLength= ',out5)
        set(handles.text2,'string',out5)
% --------------------------------------------------------------------
function Untitled_48_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_48 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
        fprintf(s,':acquire:lenght5')
        fprintf(s,':acquire:length?')
        out6=fscanf(s);
        out6=strcat('RecordLength= ',out6)
        set(handles.text2,'string',out6)
% --------------------------------------------------------------------
function Untitled_49_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_49 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
        fprintf(s,':acquire:lenght6')
        fprintf(s,':acquire:length?')
        out7=fscanf(s);
        out7=strcat('RecordLength= ',out7)
        set(handles.text2,'string',out7)
% --------------------------------------------------------------------
function Untitled_50_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_50 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
        fprintf(s,':acquire:lenght7')
        fprintf(s,':acquire:length?')
        out8=fscanf(s);
        out8=strcat('RecordLength= ',out8)
        set(handles.text2,'string',out8)

% --------------------------------------------------------------------
function Untitled_53_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_53 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
set(handles.text2,'string',' ')

% --------------------------------------------------------------------
function Untitled_54_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_54 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
        fprintf(s,':acquire1:memory?')
        out1=fscanf(s);
        set(handles.text2,'string',out1)
% --------------------------------------------------------------------
function Untitled_55_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_55 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
        fprintf(s,':acquire1:point')
        out2=fscanf(s);
%       out2=hex2dec(out2);
        out2=num2str(out2);
        set(handles.text2,'string',out2)
% --------------------------------------------------------------------
function Untitled_57_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_57 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
s=handles.data;
fprintf(s,'*idn?')
        out1=fscanf(s);
        set(handles.text2,'string',out1)

% --------------------------------------------------------------------
function Untitled_58_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_58 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
        fprintf(s,'*lrn?')
        out2=fscanf(s);
        set(handles.text2,'string',out2)
% --------------------------------------------------------------------
function Untitled_59_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_59 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
        fprintf(s,'*wai?')
        out3=fscanf(s);
        set(handles.text2,'string',out3)
% --------------------------------------------------------------------
function Untitled_51_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_51 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

s=handles.data;
fclose(s);
nn=s.status;
nn=strcat('COM1= ',nn)
set(handles.text2,'string',nn)
clear

waveformm

% --------------------------------------------------------------------
function Untitled_52_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_52 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------
function Untitled_56_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_56 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------
function Untitled_61_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_61 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------
function Untitled_62_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_62 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------
function Untitled_63_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_63 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------
function Untitled_64_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_64 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------
function Untitled_60_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_60 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------
function Untitled_65_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_65 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------
function Untitled_67_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_67 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

set(handles.popupmenu11,'enable','off');
set(handles.popupmenu6,'enable','off');
set(handles.popupmenu5,'enable','off');
set(handles.popupmenu4,'enable','off');
set(handles.popupmenu9,'enable','off');
set(handles.popupmenu10,'enable','off');
set(handles.togglebutton2,'enable','off');
set(handles.pushbutton6,'enable','off');
set(handles.popupmenu3,'enable','off');
set(handles.popupmenu2,'enable','off');

set(handles.radiobutton4,'enable','on');
set(handles.radiobutton5,'enable','on');
set(handles.radiobutton6,'enable','on');
set(handles.radiobutton7,'enable','on');
set(handles.slider1,'enable','on');
set(handles.slider2,'enable','on');

% --------------------------------------------------------------------
function Untitled_68_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_68 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

set(handles.radiobutton4,'enable','off');
set(handles.radiobutton5,'enable','off');
set(handles.radiobutton6,'enable','off');
set(handles.radiobutton7,'enable','off');
set(handles.slider1,'enable','off');
set(handles.slider2,'enable','off');

set(handles.popupmenu11,'enable','on');
set(handles.popupmenu6,'enable','on');
set(handles.popupmenu5,'enable','on');
set(handles.popupmenu4,'enable','on');
set(handles.popupmenu9,'enable','on');
set(handles.popupmenu10,'enable','on');
set(handles.togglebutton2,'enable','on');
set(handles.pushbutton6,'enable','on');
set(handles.popupmenu3,'enable','on');
set(handles.popupmenu2,'enable','on');

% --------------------------------------------------------------------
function Untitled_66_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_66 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------
function Untitled_70_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_70 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------
function Untitled_72_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_72 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

load idd;
load freq;
load a;

if idd == '0'
    set(handles.text2,'string','No Graph To Save');
    pause(2);
    set(handles.text2,'string',' ');
else
    set(handles.text2,'string','Graph Saved');
    pause(2);
    set(handles.text2,'string',' ');
end

save head a freq idd;

% --------------------------------------------------------------------
function Untitled_73_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_73 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

load head;

if idd == '1'
    t=-8:0.001:8;
    y=a*sin(2*pi*freq*t);
    axis(handles.axes1);
    plot(t,y);
    axis([-8 8 -10 10]);
    set(handles.text2,'string','Graph Loaded');
    pause(2);
    set(handles.text2,'string',' ');
elseif idd == '2'
    t1=-8:0.001:8;
    y=a*cos(2*pi*freq*t1);
    axis(handles.axes1);
    plot(t1,y,'r');
    axis([-8 8 -10 10]);
    set(handles.text2,'string','Graph Loaded');
    pause(2);
    set(handles.text2,'string',' ');
elseif idd == '3'
    t2=-8:0.001:8;
    y=a*tan(2*pi*freq*t2);
    axis(handles.axes1);
    plot(t2,y,'k');
    axis([-8 8 -10 10]);
    set(handles.text2,'string','Graph Loaded');
    pause(2);
    set(handles.text2,'string',' ');
elseif idd == '4'
    t3=-8:0.001:8;
    y=a*square(2*pi*freq*t3);
    axis(handles.axes1);
    plot(t3,y,'m');
    axis([-8 8 -10 10]);
    set(handles.text2,'string','Graph Loaded');
    pause(2);
    set(handles.text2,'string',' ');
end

% --------------------------------------------------------------------
function Untitled_71_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_71 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------
function Untitled_75_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_75 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

grid minor;

% --------------------------------------------------------------------
function Untitled_76_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_76 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

grid off;

% --------------------------------------------------------------------
function Untitled_74_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_74 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

author: Sable

repo: mcbench-benchmarks


text:
function x = u1_to_sphere_unit_2d ( u )

%*****************************************************************************80
%
%% U1_TO_SPHERE_UNIT_2D maps a point in the unit interval onto the unit sphere in 2D.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    06 July 2004
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, real U, a point in the unit interval.
%
%    Output, real X(2), the corresponding point on the circle.
%
  angle = 2.0 * pi * u(1);

  x(1) = cos ( angle );
  x(2) = sin ( angle );

  return
end


text:
% [INPUT]
% r = A float t-by-n matrix (-Inf,Inf) representing the logarithmic returns.
% sst = A float (0.0,0.1] representing the statistical significance threshold for the linear Granger-causality test (optional, default=0.05).
% rp = A boolean indicating whether to use robust p-values for the linear Granger-causality test (optional, default=false).
%
% [OUTPUT]
% am = A binary n-by-n matrix {0;1} representing the adjcency matrix.

function am = causal_adjacency(varargin)

    persistent ip;

    if (isempty(ip))
        ip = inputParser();
        ip.addRequired('r',@(x)validateattributes(x,{'double'},{'real' '2d' 'nonempty'}));
        ip.addOptional('sst',0.05,@(x)validateattributes(x,{'double'},{'real' 'finite' '>' 0 '<=' 0.1 'scalar'}));
        ip.addOptional('rp',false,@(x)validateattributes(x,{'logical'},{'scalar'}));
    end

    ip.parse(varargin{:});

    ipr = ip.Results;
    r = validate_input(ipr.r);
    sst = ipr.sst;
    rp = ipr.rp;

    nargoutchk(1,1);

    am = causal_adjacency_internal(r,sst,rp);

end

function am = causal_adjacency_internal(r,sst,rp)

    up = isempty(getCurrentTask());

    n = size(r,2);

    nan_indices = any(isnan(r),1);
    nok = sum(~nan_indices);

    seq = (1:n).';
    seq(nan_indices) = [];

    i = repelem(seq,nok,1);
    j = repmat(seq,nok,1);

    indices = i == j;
    i(indices) = [];
    j(indices) = [];

    r_in = arrayfun(@(x)r(:,x),i,'UniformOutput',false);
    r_out = arrayfun(@(x)r(:,x),j,'UniformOutput',false);

    k = nok^2 - nok;
    pvals = zeros(k,1);

    if (rp)
        if (up)
            parfor y = 1:k
                [~,pvals(y)] = linear_granger_causality(r_in{y},r_out{y});
            end
        else
            for y = 1:k
                [~,pvals(y)] = linear_granger_causality(r_in{y},r_out{y});
            end
        end
    else
        if (up)
            parfor y = 1:k
                [pvals(y),~] = linear_granger_causality(r_in{y},r_out{y});
            end
        else
            for y = 1:k
                [pvals(y),~] = linear_granger_causality(r_in{y},r_out{y});
            end
        end
    end

    am = zeros(n);
    am(sub2ind([n n],i,j)) = pvals < sst;

end

function [b,c,r] = hac_regression(y,x,ratio)

    t = length(y);

    [b,~,r] = regress(y,x);

    h = diag(r) * x;
    q_hat = (x.' * x) / t;
    o_hat = (h.' * h) / t;

    l = round(ratio * t,0);

    for i = 1:(l - 1)
        o_tmp = (h(1:(t-i),:).' * h((1+i):t,:)) / (t - i);
        o_hat = o_hat + (((l - i) / l) * (o_tmp + o_tmp.'));
    end

    c = linsolve(q_hat,o_hat) / q_hat;

end

function [pval,pval_robust] = linear_granger_causality(in,out)

    t = length(in);
    y = out(2:t,1);
    x = [out(1:t-1) in(1:t-1)];

    [b,c,r] = hac_regression(y,x,0.1);

    xxi = inv(x.' * x);
    s2 = (r.' * r) / (t - 3);
    t_coefficients = b(2) / sqrt(s2 * xxi(2,2));

    pval = 1 - normcdf(t_coefficients);
    pval_robust = 1 - normcdf(b(2) / sqrt(c(2,2) / (t - 1)));

end

function r = validate_input(r)

    [t,n] = size(r);

    if ((t < 5) || (n < 2))
        error('The value of ''r'' is invalid. Expected input to be a matrix with a minimum size of 5x2.');
    end

end

author: TommasoBelluzzo

repo: SystemicRisk


%% REW_riverbank
% %{
imfolder = 'images\REW_riverbank';
im_n = 2;
imfile = cell(im_n,1);
imfile{1} = [imfolder '\' 'riverbank_01.jpg'];
imfile{2} = [imfolder '\' 'riverbank_02.jpg'];

im = cell(im_n,1);
for ii = 1:im_n
    im{ii} = imread(imfile{ii});
end

edge_list = [1,2];

imsize = zeros(im_n,3);

for ii = 1:im_n
    imsize(ii,:) = size(im{ii});
    if imsize(ii,1) > 720
        scale = 720/size(im{ii}, 1);
        im{ii} = imresize(im{ii}, scale);

        imsize(ii,:) = size(im{ii});
    end
end

mosaic = REW_mosaic( im, edge_list, 1, 'persp', 0, imfolder );
%}


text:
function [engine, loglik] = enter_evidence(engine, evidence, varargin)
% ENTER_EVIDENCE Add the specified evidence to the network (jtree_unrolled_dbn)
% [engine, loglik] = enter_evidence(engine, evidence, ...)
%
% evidence{i,t} = [] if if X(i,t) is hidden, and otherwise contains its observed value (scalar or column vector)
%
% The following optional arguments can be specified in the form of name/value pairs:
% [default value in brackets]
%
% maximize - if 1, does max-product instead of sum-product [0]
% filter   - if 1, does filtering (not supported), else smoothing [0]
%
% e.g., engine = enter_evidence(engine, ev, 'maximize', 1)

maximize = 0;
filter = 0;

% parse optional params
args = varargin;
nargs = length(args);
if nargs > 0
  for i=1:2:nargs
    switch args{i},
     case 'maximize', maximize = args{i+1};
     case 'filter',  filter = args{i+1};
     otherwise,
      error(['invalid argument name ' args{i}]);
    end
  end
end

if filter
  error('jtree_unrolled_dbn does not support filtering')
end

if size(evidence,2) ~= engine.nslices
  error(['engine was created assuming there are ' num2str(engine.nslices) ...
	 ' slices, but evidence has ' num2str(size(evidence,2))])
end

[engine.unrolled_engine, loglik] = enter_evidence(engine.unrolled_engine, evidence, 'maximize', maximize);

author: bayesnet

repo: bnt

save_path: github-repos/MATLAB/bayesnet-bnt


text:
function [assignment,cost] = munkres(costMat)
% version 2.3 by Yi Cao at Cranfield University on 11th September 2011
%
% MUNKRES   Munkres (Hungarian) Algorithm for Linear Assignment Problem.
%
% [ASSIGN,COST] = munkres(COSTMAT) returns the optimal column indices,
% ASSIGN assigned to each row and the minimum COST based on the assignment
% problem represented by the COSTMAT, where the (i,j)th element represents
% the cost to assign the jth job to the ith worker.
%
% Partial assignment: This code can identify a partial assignment is a full
% assignment is not feasible. For a partial assignment, there are some
% zero elements in the returning assignment vector, which indicate
% un-assigned tasks. The cost returned only contains the cost of partially
% assigned tasks.

% This is vectorized implementation of the algorithm. It is the fastest
% among all Matlab implementations of the algorithm.

% Examples
% Example 1: a 5 x 5 example
%{
[assignment,cost] = munkres(magic(5));
disp(assignment); % 3 2 1 5 4
disp(cost); %15
%}
% Example 2: 400 x 400 random data
%{
n=400;
A=rand(n);
tic
[a,b]=munkres(A);
toc                 % about 2 seconds
%}
% Example 3: rectangular assignment with inf costs
%{
A=rand(10,7);
A(A>0.7)=Inf;
[a,b]=munkres(A);
%}
% Example 4: an example of partial assignment
%{
A = [1 3 Inf; Inf Inf 5; Inf Inf 0.5];
[a,b]=munkres(A)
%}
% a = [1 0 3]
% b = 1.5
% Reference:
% "Munkres' Assignment Algorithm, Modified for Rectangular Matrices",
% http://csclab.murraystate.edu/bob.pilgrim/445/munkres.html

% version 2.3 by Yi Cao at Cranfield University on 11th September 2011

assignment = zeros(1,size(costMat,1));
cost = 0;

validMat = costMat == costMat & costMat < Inf;
bigM = 10^(ceil(log10(sum(costMat(validMat))))+1);
costMat(~validMat) = bigM;

% costMat(costMat~=costMat)=Inf;
% validMat = costMat<Inf;
validCol = any(validMat,1);
validRow = any(validMat,2);

nRows = sum(validRow);
nCols = sum(validCol);
n = max(nRows,nCols);
if ~n
    return
end

maxv=10*max(costMat(validMat));

dMat = zeros(n) + maxv;
dMat(1:nRows,1:nCols) = costMat(validRow,validCol);

%*************************************************
% Munkres' Assignment Algorithm starts here
%*************************************************

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   STEP 1: Subtract the row minimum from each row.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
minR = min(dMat,[],2);
minC = min(bsxfun(@minus, dMat, minR));

%**************************************************************************
%   STEP 2: Find a zero of dMat. If there are no starred zeros in its
%           column or row start the zero. Repeat for each zero
%**************************************************************************
zP = dMat == bsxfun(@plus, minC, minR);

starZ = zeros(n,1);
while any(zP(:))
    [r,c]=find(zP,1);
    starZ(r)=c;
    zP(r,:)=false;
    zP(:,c)=false;
end

while 1
%**************************************************************************
%   STEP 3: Cover each column with a starred zero. If all the columns are
%           covered then the matching is maximum
%**************************************************************************
    if all(starZ>0)
        break
    end
    coverColumn = false(1,n);
    coverColumn(starZ(starZ>0))=true;
    coverRow = false(n,1);
    primeZ = zeros(n,1);
    [rIdx, cIdx] = find(dMat(~coverRow,~coverColumn)==bsxfun(@plus,minR(~coverRow),minC(~coverColumn)));
    while 1
        %**************************************************************************
        %   STEP 4: Find a noncovered zero and prime it.  If there is no starred
        %           zero in the row containing this primed zero, Go to Step 5.
        %           Otherwise, cover this row and uncover the column containing
        %           the starred zero. Continue in this manner until there are no
        %           uncovered zeros left. Save the smallest uncovered value and
        %           Go to Step 6.
        %**************************************************************************
        cR = find(~coverRow);
        cC = find(~coverColumn);
        rIdx = cR(rIdx);
        cIdx = cC(cIdx);
        Step = 6;
        while ~isempty(cIdx)
            uZr = rIdx(1);
            uZc = cIdx(1);
            primeZ(uZr) = uZc;
            stz = starZ(uZr);
            if ~stz
                Step = 5;
                break;
            end
            coverRow(uZr) = true;
            coverColumn(stz) = false;
            z = rIdx==uZr;
            rIdx(z) = [];
            cIdx(z) = [];
            cR = find(~coverRow);
            z = dMat(~coverRow,stz) == minR(~coverRow) + minC(stz);
            rIdx = [rIdx(:);cR(z)];
            cIdx = [cIdx(:);stz(ones(sum(z),1))];
        end
        if Step == 6
            % *************************************************************************
            % STEP 6: Add the minimum uncovered value to every element of each covered
            %         row, and subtract it from every element of each uncovered column.
            %         Return to Step 4 without altering any stars, primes, or covered lines.
            %**************************************************************************
            [minval,rIdx,cIdx]=outerplus(dMat(~coverRow,~coverColumn),minR(~coverRow),minC(~coverColumn));
            minC(~coverColumn) = minC(~coverColumn) + minval;
            minR(coverRow) = minR(coverRow) - minval;
        else
            break
        end
    end
    %**************************************************************************
    % STEP 5:
    %  Construct a series of alternating primed and starred zeros as
    %  follows:
    %  Let Z0 represent the uncovered primed zero found in Step 4.
    %  Let Z1 denote the starred zero in the column of Z0 (if any).
    %  Let Z2 denote the primed zero in the row of Z1 (there will always
    %  be one).  Continue until the series terminates at a primed zero
    %  that has no starred zero in its column.  Unstar each starred
    %  zero of the series, star each primed zero of the series, erase
    %  all primes and uncover every line in the matrix.  Return to Step 3.
    %**************************************************************************
    rowZ1 = find(starZ==uZc);
    starZ(uZr)=uZc;
    while rowZ1>0
        starZ(rowZ1)=0;
        uZc = primeZ(rowZ1);
        uZr = rowZ1;
        rowZ1 = find(starZ==uZc);
        starZ(uZr)=uZc;
    end
end

% Cost of assignment
rowIdx = find(validRow);
colIdx = find(validCol);
starZ = starZ(1:nRows);
vIdx = starZ <= nCols;
assignment(rowIdx(vIdx)) = colIdx(starZ(vIdx));
pass = assignment(assignment>0);
pass(~diag(validMat(assignment>0,pass))) = 0;
assignment(assignment>0) = pass;
cost = trace(costMat(assignment>0,assignment(assignment>0)));

function [minval,rIdx,cIdx]=outerplus(M,x,y)
ny=size(M,2);
minval=inf;
for c=1:ny
    M(:,c)=M(:,c)-(x+y(c));
    minval = min(minval,min(M(:,c)));
end
[rIdx,cIdx]=find(M==minval);

author: OHBA-analysis

repo: HMM-MAR


text:
function getHeaderSize(in)
%
%
if notDefined('in');
    in = '';
else
    warning('Obsolete funciton');
end

disp(in);

return

author: vistalab

repo: vistasoft

save_path: github-repos/MATLAB/vistalab-vistasoft


text:
%% Perceptually Uniform Colormaps from MatPlotLib
% The <www.mathworks.com/matlabcentral/fileexchange/62729
% MatPlotLib Perceptually Uniform Colormaps> submission includes the
% default colormap family and default line colororder family from
% MatPlotLib 2 and 3. This document shows examples of their usage.
%% Overview
matplotlib_plot
%% |VIRIDIS| Default Colormap
close()
load spine
image(X)
colormap(viridis)
%% |CIVIDIS|
colormap(cividis)
%% |INFERNO|
colormap(inferno)
%% |MAGMA|
colormap(magma)
%% |PLASMA|
colormap(plasma)
%% |TWILIGHT|  (cyclical)
colormap(twilight)
%% |TAB10| Default Line ColorOrder
N = 20;
clf()
axes('ColorOrder',tab10(N),'NextPlot','replacechildren')
X = linspace(0,pi*3,1000);
Y = bsxfun(@(x,n)n*sin(x+2*n*pi/N), X(:), 1:N);
plot(X,Y, 'linewidth',4)
%% |TAB20|
clf()
axes('ColorOrder',tab20(N),'NextPlot','replacechildren')
plot(X,Y, 'linewidth',4)
%% |TAB20B|
clf()
axes('ColorOrder',tab20b(N),'NextPlot','replacechildren')
plot(X,Y, 'linewidth',4)
%% |TAB20C|
clf()
axes('ColorOrder',tab20c(N),'NextPlot','replacechildren')
plot(X,Y, 'linewidth',4)

author: kavli-ntnu


text:
function  sParams = rmCreateStim(vw,curStim)
%Create default the retinotopy model stimulus parameter structure
%
%  sParams = rmCreateStim([vw],[curStim]);
%
% This is the modern one.  The older form is rmStimCreate - which is used
% by the older GUI (rmEditStimulusParameters).  When that goes away
% rmStimCreate can also go away. This one works with rmEditStimParams).
%
%Example:
%    sParams = rmCreateStim;   % Create an array with the default
%    sParams = rmCreateStim(vw,myStimParams); % Overlay myStimParams values
%
% JW Jan, 2008
% SD: getCurView is order dependent (gets inplanes first and since we
% typically use the volume/gray view it gets the incorrect one if you have
% an inplane open. Safer to propogate the view structure.
% JW: added argin curStim so that a stim template can be made from just a
% single scan if requested. and not necessarily all the scans in the view's
% current dataTYPE

if ~exist('vw','var') || isempty(vw)
    vw = getCurView; % careful getCurView is unreliable (order dependent)
end

if ~exist('curStim', 'var') || isempty(curStim)
    sParams = rmStimTemplate(vw);
    curStim = length(sParams);
else
    sParams = rmStimTemplate(vw, length(curStim));
end

% Loop through each of the curStim fields and copy the values into the
% sParams fields.
s = fieldnames(sParams(1));
for ii=1:length(curStim)
    for jj=1:length(s)
        if isfield(curStim(ii),s{jj})
            sParams(ii).(s{jj}) = curStim(ii).(s{jj});
        end
    end
end

return;


text:
% getchanlist() - Obtain indices of specified channel types.
%
% Usage:
%       >> chanlist = getchanlist(chanlocs, type)
%
% Inputs:
%     chanlocs - EEGLAB channel location structure
%     type     - [string] select channel of specified type
%                can enter a cell array to select several channel types
%
% Output:
%     chanlist - list of channel indices for the selected type(s)
%                sorted in increasing order
%
% Note: this function is not case sensitive
%
% Author: Arnaud Delorme, SCCN, INC, UCSD, 2004
%
% See also: pop_chanedit()

% Copyright (C) Arnaud Delorme, SCCN, INC, UCSD, 2004
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% (at your option) any later version.
%
% This program 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 this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

function chanlist = getchanlist(chanlocs, type)

    if nargin < 1
        help getchanlist;
        return;
    end;

    if nargin < 2 || ~isfield(chanlocs, 'type')
        chanlist = [1:length(chanlocs)];
        return;
    end;

    % search channel types
    % --------------------
    if isstr(type), type = { type }; end;
    type = lower(type);
    chanlist = [];
    alltypes = lower({ chanlocs.type });
    for index = 1:length(type)
        tmplist = strmatch(type{index}, alltypes, 'exact');
        if isempty(tmplist)
            fprintf('Warning: no channel of type ''%s'' found\n', type{index});
        end;
        chanlist = [ chanlist tmplist' ];
    end;
    chanlist = sort(chanlist);

author: PatternRecognition

repo: OpenBMI