text stringlengths 8 6.12M |
|---|
%
% Copyright (c) 2015, Mostapha Kalami Heris & Yarpiz (www.yarpiz.com)
% All rights reserved. Please read the "LICENSE" file for license terms.
%
% Project Code: YOEA112
% Project Title: Implementation of Firefly Algorithm (FA) in MATLAB
% Publisher: Yarpiz (www.yarpiz.com)
%
% Developer: Mostapha Kalami Heris (Membe... |
% rl agents2
clear all;
nLocations = 4;
nU = 10;
nF = 10;
pUdown = .002;
pUup = .0003;
pFup = .005;
pFdown = .02;
nTimesteps = 36001;
states = zeros(1,nTimesteps);
actions = zeros(1,nTimesteps);
rewards = zeros(1,nTimesteps);
states(1) = 1;
moveCost = -.1;
locationRewards = [-.001 1 1.25 .57];
utility(1) = nU;
fatig... |
%--------------------------------------------------------------------------
% Name: CleanText.m
%
% Description: Eliminates non-letter symbols from input text.
%
% Inputs: Text - input text
%
% Outputs: Text - input text without non-letter ... |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Rewrite derivatives in terms of few basic derivatives
% written by Matthis Thorade
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear;
clc;
% independent vars and base props
syms R D T P;
syms fi fit fitt fittt... |
function recurs = mysameio(This)
% mysameio [Not a public function]
%
% Backend IRIS function.
% No help provided.
% -IRIS Macroeconomic Modeling Toolbox.
% -Copyright (c) 2007-2017 IRIS Solutions Team.
inVars = unique(cellfun(@(x) x{1},regexp(This.Inputs,'\{[-\+]?\d*}','split'),'UniformOutput',false)) ;
outVars =... |
function subs = ind2sub_pa(dims, i)
% Convert a linear index i into a set of subscripts based on the values
% given in dims.
%
% Matlab style 1-indexing
%
if min(size(dims)) > 1 || numel(size(dims)) ~= 2
error('ind2sub_pa : dimensions not appropriate');
end
if size(dims, 2) == 1
dims = dims.';
end
cycleLengths =... |
function [ outpt ] = GetFirstNeighbor( mask, idx, visitedList,direction )
% GetFirstNeighbor.m - Find the first contiguous neighbor in the mask file
%
% Inputs
% mask = list [row,col] of foreground pixels in the binary mask created in FIJI
% idx = index of the point around which we will search for a contiguous... |
gamma = 70e-3; % surface tension constant N/m
l = 5e-6; % distance between fibre centres in m
R = l/2; % radius of fibres
rho = 997; % water density kg/m^3
Hmin = 0;
Hmax = 0.1; % water thickness
n = 100; % number of points
H = linspace(Hmin,Hmax,n);
g= 9.8; % gravitational constant m/s
p=rho*g*H; % pressure at interf... |
%TrainingData_File='csv_data/train_d.csv';TestingData_File='csv_data/test_d.csv'; FileName='input_data/helm_input_d';
%TrainingData_File='csv_data/train_w.csv';TestingData_File='csv_data/test_w.csv'; FileName='input_data/helm_input_w';
%TrainingData_File='csv_data/train_dw.csv';TestingData_File='csv_data/test_dw.csv'; ... |
runData = extract_signal_runs(folderName,loadStateCodeStr,params.params_loading);
%% Bipolar EMG
runEMGData= remove_channels_runs(runData,{[1:16 19:34]});
for iRun = 1:length(runEMGData)
dataEMG = runEMGData{iRun}.data(1,:)- runEMGData{iRun}.data(2,:);
runEMGData{iRun}.data(1,:) = dataEMG;
runEMGData{... |
function plotXY(t, strainMatrix, nodeIDs)
%plotXY(xy, anchorNodes, truexy, bx, strainMatrix, kd, nodeIDs)
%
%this function will plot the points xy and the node ids if they are passed
if ~isfield(t, 'xyEstimate') t.xyEstimate = t.xy; end
if nargin<2 | isempty(strainMatrix) strainMatrix = zeros(size(t.xyEstimate,1... |
%% scatter of decoding accuracy v roi size
scripts_dir = ''; % PATH TO SCRIPTS DIRECTORY
fig_dir = [scripts_dir, '/Figures'];
data_file = [fig_dir, '/source_data/Source Data.xls'];
% load data
T = readtable(data_file, 'Sheet', 'S2E', 'Range', 'A2:E601');
T.Properties.VariableNames = {'Subject', 'ROI', 'Cortical', 'Vo... |
function [C, sigma] = dataset3Params(X, y, Xval, yval)
%EX6PARAMS returns your choice of C and sigma for Part 3 of the exercise
%where you select the optimal (C, sigma) learning parameters to use for SVM
%with RBF kernel
% [C, sigma] = EX6PARAMS(X, y, Xval, yval) returns your choice of C and
% sigma. You should co... |
%% Extraction of EEG data from the Brain Vision VHDR files
% Other data added to the data structure:
% >> 'gain' = 0.1 (needed to convert resolution bits to microVolts)
% >> 'eventTriggers' = (all triggers pressed by the pushbutton during
% experiment session)
% >> 'ExperStartInd' = (event marker tha... |
function [l_max, x_p, f_x, info, out_m, time] = fproj(z, a)
asq = a.^2;
f = @(l) sum(( z.^2 ./ ( ( (1 + ( l ./ asq) ) ).^2 .* asq))) - 1;
a_min = min(a);
a_max = max(a);
l_mn = 0;
y = z*min(a)/norm(z);
l_mx = (z - y)' * (z - y)
[l_max, fv_max, info_max, outp_max] = fzero(f, [l_mn, l_mx]);
x_p = z ./ (1 + l_max .... |
fid = fopen('inp2.BTC','w');
N = 3000;
alt = 10000*rand(N,1);
dtamb = -40+80*rand(N,1);
%XM = 0.8*rand(N,1);
XM = zeros(N,1);
ZXN_HPC = 0.6+0.4*rand(N,1);
delta2 = ((1-0.0065*alt/288.15).^5.2561) ...
.*((1+0.2*XM.*XM).^3.5);
%PWX = (-3000+6000*rand(N,1)).*(ZXN_HPC.^3).*delta2;
PWX = zeros(N,1);
... |
%% snaps any state to the center of the appropriate cell in the current grid
% For some reasons, there is some residue remaining after computations!
function cellRange = getCellRange(X,grid_eps)
cellRange = [(X - grid_eps/2)' (X + grid_eps/2)'];
end
|
function out = ardSerialEcho(loc)
global USB;
global ardVar;
list = [ardVar.ee,ardVar.SerialEcho,loc,0,0,0,0,ardVar.ee];
fwrite(USB, uint8(size(list,2)), 'uint8','sync');
for i=1:size(list,2)
fwrite(USB, uint8(list(i)), 'uint8','sync');
end
num = fread(USB, 2, 'uin... |
function y = normw(x,wt)
% To compute the weighted norm of x with repect to
% the weighting vector wt, this subroutine will be used in
% the weighted Arnoldi process;
% Written by Dr. Zhao-Li Shen (SCIAU)
y = sqrt(x'*(x.*wt));
end |
function cvVal = findCV (resultant)
% This function calculates the coefficient of variation (CV)
% INPUT resultant -> input vector
% OUTPUT cvVal -> scalar, coefficient of variation value
% Finding MEAN
meanVal = mean(resultant);%#codegen
% Finding standard deviation
varVal = std(resultant(:));%standard deviation
% ... |
viz.basis = situations{1}{1}.base_sim; % Normal
k_gb = viz.basis.param(3);
study_base = retrieve_study(6);
delta = [1:15];
for it = 1:length(delta)
viz.demo{it} = viz.basis;
viz.demo{it}.param(3) = k_gb / delta(it);
% Setup demonstration run basis
viz.demo{it}.inst... |
function [E, E_train, explained] = E_matrix(Data, size_train,length_window,varargin)
% PCA - Test and Train
% This function runs PCA on training data. Then it transform all the data
% by using the principal compent coefficant. Afterwards it calculates the
% energy for each PC in each window. Energy is defined as
... |
classdef rlJoint < rlTransform
properties
position;
velocity;
acceleration;
end
methods
function obj = rlJoint(c_ptr)
%C++ pointer stuff
obj = obj@rlTransform(c_ptr);
%Get the type of joint
obj.type = DynamicsModelMatlab... |
function out = randSymMat(n, i)
maxRnd = i/2;
A = randi([-maxRnd,maxRnd],n,n);
out = A + A';
end
|
clear;
% Load our data set
load('proj_fit_22');
x1=id.X{1, 1};
x2=id.X{2, 1};
y=id.Y;
m=2; % degree for the polynomial approximator
fii = fi_part1(m,x1,x2,y); % regressors matrix
yhi= yhat_part1(fii,y); % the approximated matrix
MSEi = mse_part1(y,yhi); % mean square error
figure;
plot(MSEi);
title('M... |
function logProb = lm_prob(sentence, LM, type, delta, vocabSize)
%
% lm_prob
%
% This function computes the LOG probability of a sentence, given a
% language model and whether or not to apply add-delta smoothing
%
% INPUTS:
%
% sentence : (string) The sentence whose probability we wish
% ... |
function [fs] = ExtractGridHistogram(im, ngrids, nbins)
xs = floor(linspace(1, size(im, 2) + 1, ngrids + 1));
ys = floor(linspace(1, size(im, 1) + 1, ngrids + 1));
fs = [];
for i=1:ngrids
ii = xs(i):xs(i+1)-1;
for j=1:ngrids
jj = ys(j):ys(j+1)-1;
impatch = im(jj,... |
function varargout = printStat(vec, useSD, showN)
% PRINTSTAT
%
% Description:
% Print basic stats to cmd line in format: MEAN +- SEM (N)
%
% Input:
% vec Data (vector, or matrix with rows = separate data)
% Optional input:
% useSD Use SD instead of SEM (default = false)
% showN ... |
function answer = arr2dec(arr)
n = numel(arr);
if(arr(n)==0)
arr_sum = int64(0);
for i=1:n
arr_sum = arr_sum + (2^(i-1))*arr(i);
end
answer = (arr_sum);
else
arr_sum = int64(-2^(n-1));
for i = 1:n-1
arr_sum = arr_sum + (2^(i-1))*arr(i);
end
answer = (arr_sum);
end
end
|
% The C chord recording is stored in a file named Cchord.mat. This file contains two variables:
% y: signal from recording
% fs: sampling frequency
load Cchord.mat
n = numel(y)
t = (0:1:n-1)
% arithmetic operation on t
% plotting y against t
t = t/fs
plot(t,y)
% storing the absolute value of the fourier transformati... |
function[x,n] = comlex_value_seq(sigma, omega0, n1, n2)
clc;
n = (n1:n2);
x = exp((sigma + li * omega0).^n);
Hs = stem(n, x, 'm', 'filled');
set(Hs, 'markersize', 4);
|
function [param, traj_load, segmentInfo] = setup_main(filesToload, manSegLoadPath, currFilestack, mode, runSettings, cost_function_names, feature_load_names, extraSettings)
% a common setup file for main_direct and main_inverse
% parse the input runSettings.varaibleFactors
p = inputParser;
p.KeepUnmatched = true;
add... |
imaqreset
clear variables
path = 'C:\Users\60069978\Documents\MATLAB\medicion25\';
[socketID, positioner_x, positioner_y, group_x, group_y] = setup_stages();
tol = 1e-3;
set(0,'DefaultFigureVisible', 'on')
%%
mover_stage_2(socketID, group_y, positioner_y, 500, tol);
mover_stage_2(socketID, group_x, po... |
function phenotypeFactor = constructSigmoidPhenotypeFactor(alleleWeights, geneCopyVarOneList, geneCopyVarTwoList, phenotypeVar)
% This function takes a cell array of alleles' weights and constructs a
% factor expressing a sigmoid CPD.
%
% You can assume that there are only 2 genes involved in the CPD.
%
% In the... |
function distrib_plot(parameters, app, exp_num)
cla(app.DistributionPlot)
weight_sum = sum(parameters.weights{exp_num});
bar(app.DistributionPlot,parameters.diff_coefs{exp_num},parameters.weights{exp_num}/weight_sum,0.1);
end
|
function[X F V] = gmergefiber(X,F,V)
%GMERGEFIBER - merge 2 fibers together
%if a handles structure is used instead of three seperate inputs
if nargin==1
handles = X;
X = handles.X;
F = handles.F;
V = handles.V;
end
%get the datatip object
dcm_obj = datacursormode(gcf);
... |
function res = invspecgram(B,NFFT,Fs,WINDOW,NOVERLAP)
% res = invspecgram(B,NFFT,Fs,WINDOW,NOVERLAP)
% All parameters are like SPECGRAM.
if ((nargin<2)|isempty(NFFT))
NFFT=256;
end
if ((nargin<3)|isempty(Fs))
Fs=2;
end
if ((nargin<4)|isempty(WINDOW))
WINDOW=hanning(NFFT);
end
if ((nargin<5)|isempt... |
% rank_test - Check the contribution of each trascription factor to the total rank in A
%
% Usage:
% [res,d_rank]=Rank_test(A)
%
% res contains the number of TF and its rank in each row
% d_rank contains the number of TF and its rank with rank problem
function [res,d_rank]=rank_test(A)
[N,L]= s... |
function varargout = Rotate(varargin)
% ROTATE MATLAB code for Rotate.fig
% ROTATE, by itself, creates a new ROTATE or raises the existing
% singleton*.
%
% H = ROTATE returns the handle to a new ROTATE or the handle to
% the existing singleton*.
%
% ROTATE('CALLBACK',hObject,eventData,handles,... |
function [x,Testing_time] = test_LBS(test_x,BLS_regressors_icascade,options,current_cascade )
beta2 = BLS_regressors_icascade.beta2;
beta11 = BLS_regressors_icascade.beta11;
ps = BLS_regressors_icascade.ps;
wh = BLS_regressors_icascade.wh{1};
l2 = BLS_regressors_icascade.l2;
s = optio... |
clear;clc;close all
addpath('dataset/facebook')
addpath('functions')
addpath('functions/graph_related_functions')
edgeList = csvread('facebook_edge_list.csv');
N = max(max(edgeList));
P = N;
A = full(sparse(edgeList(:, 1), edgeList(:, 2), 1, N, N));
A = sparse(A+A');
K = 10; % num of communities
load 'comm.mat'
... |
function [vel, done] = pidMobile(cur,goal, Kv, Kw)
%PIDMOBILE Summary of this function goes here
% pose - [x, y, theta]
% goal - [x, y]
% Kv, Kw - [Kp, Ki, Kd]
tol = 0.5;
% Compute error
er = goal - cur(1:2);
% Compute v
v = Kv(1)*sqrt(er(1)^2 + er(2)^2);
if (abs(v) < tol)
v = 0;
end
%Compute w
if (v < tol)
... |
function [f, EMUstate,v,fMID_diff] =...
leastSQ_SS(x,EMUstate,pEntries,isRevPivot,par,ns_free,v_fixed,fluxStoicT,...
A_cell,B_cell,Amap,Bmap,cauchyMap,knownMapLHS,calcMapLHS,knownMap,calcMap,noEMUperm,...
noExpData,dataMet,dataMetMID_SIMvect,dataMetMID_EXPvect,dataMetMID_SEvect,...
additionalData)
xFl... |
function adjacent=isAdjacentToOpponent(board,turn)
adjacent=false;
head=turn*10+turn;
[hRow hCol]=find(board==head);
turn=changeTurn(turn);
opponent=turn*10+turn;
[oRow oCol]=find(board==opponent);
rowDiff=abs(hRow-oRow);
colDiff=abs(hCol-oCol);
if ( ((rowDiff==1) && (rowDiff == 0)) || ((colDiff == 1) && (... |
function [fitresult, gof] = createFit(E_list_cropped, BG_cropped)
%CREATEFIT(E_LIST_CROPPED,BG_CROPPED)
% Create a fit.
%
% Data for 'untitled fit 1' fit:
% X Input : E_list_cropped
% Y Output: BG_cropped
% Output:
% fitresult : a fit object representing the fit.
% gof : structure with goodness-o... |
% mfile to set figure graphics to HVLab corporate colors for copying
% into powerpoint (white/yellow on blue) or for OHPs (black on white)
%
% function []=HVGRAPHRECOLOUR(fignum,use,titlefontsize,axisfontsize,nobold,titlecolor,textcolor,backcolor)
%
% all arguments are optional
% use is either 'ppt' for powerpo... |
function [Z] = generated_potential(X, Y, x_src, y_src, dist_table, dist_max, l)
norms = sqrt((X - x_src).^2 + (Y - y_src).^2);
inds=max(1,min(uint16(l.*norms./dist_max)+1, l));
Z = dist_table(inds);
|
clc;
fprintf('===============================[ tsdmfrectarray.m ]===============================\n\n');
fprintf('This example calculates the transient pressure field of an array of rectangular\n');
fprintf('transducers using the Fast Nearfield Method with Time-Space decomposition. The\n');
fprintf('elements in this... |
%fit cos curve to direction slective response
% to compare ROIs, centering by preferred direction
ang_list = 0:pi/6:23*pi/12;
x = [];
y = [];
i = imgobj.selectROI;
x_me = [];
y_me = [];
for i2 = 1:12
y_s = rmmissing(imgobj.dFF_s_each(:,i2, i));
x_s = repmat(ang_list(i2), [length(y_s),1]);
y = [y... |
function nii_infos = wave_summarise
% wrapper around spm_summarise to display information about nii
[base_dir] = wave_ghost;
% Settings
all_subs = [5:12];
anadirname = 'canonical_pmodV4';
file_templ = 's6w*.nii';
% Collect data
nii_infos = [];
niis = {};
for i = 1:numel(all_subs)
... |
function [data,surrmean,surrstd,surrhist,zscore] = computeSurrData(sdatafile)
% set constants
DATA_COL = 1;
SHIFT_COL = 2;
SURR_COL = 3;
% the kstest2 is not acurate if n1*n2/(n1+n2) < 4. Since
% the number of surrogate spikes is always going to be 1000
% times the number of real spikes, this simplifies to
% 1000n^2/1... |
function [] = demo_plot( )
%DEMO
%这是一个作图的Demo
% -----------------------
% 程刚,20160124
% 吴云峰,20160129,针对画图做了修改,适应了所有的图都能做的情况
% 吴云峰,20160215,针对calcPx的函数的变动,修改了一些作图的函数使得能够流畅画图
%% --------------------首先将变量进行赋予-------------------------
clc
clear all;
format compact
format short g;
tic;
% 填入期权信息
% tau|K|S|sigma|r有了
pric... |
function [ Z,Y,details] = Dual_APG_algorithm(sys,Ptree,Tree,V,ops)
% This function is implements the APG algorithm to solve an optimization
% problem. The inputs the system are the system dynamics, the tree
% structure, all the off-line elements that are calculated earlier that are
% to be used by the dual APG. additio... |
%% Setup fastRPCA
cd stephenbeckr-fastRPCA-ffa256a
setup_fastRPCA;
cd ..
%%Initialization, Input File
% Output: "X" is the training matrix X which contains in its columns the vectorized training face images
% "cellX" is X as cell
% "expressionLabel" is the labels for each column in X
X = [];
expression... |
function m = findMax(vol)
cylinder_1_center = vol(32,15,5+12);
cylinder_2_center = vol(50,25,16);
cylinder_3_center = vol(32,30,5+12) ;
cylinder_4_center = vol(20,30,16) ;
sphere_1_center = vol(32,45,16) ;
sphere_2_center = vol(32,55,16);
end |
% Uncrop the displayed images back to their original display widths and
% heights.
%
% Author: Elliot Tuck
% Date: 20170817
function uncrop()
% reset display width and height values
default_display_width = getappdata(0, 'default_display_width');
default_display_height = getappdata(0, 'default_display_height... |
function segmentsOfInterest = createTaskRepetitionTimeStruct()
%Added by PC. Defines struct with time information of segments of interest %in single arm sequences
segmentsOfInterest = struct;
% Values specified using original sampling rate of 200Hz
segmentsOfInterest(1).name = "Subject01_Single... |
%% A MODIFICATION OF spm_fnirs/spm_fnirs_specify1st_ui.mat TO ALLOW IT TO RUN
%% WITHOUT UI.
function spm_fnirs_specify1st_no_ui(F, fold, cond_file, first_level_params)
% Specify general linear model (GLM) of fNIRS for the 1st level analysis
% FORMAT [SPM] = spm_fnirs_specify1st_ui(F)
%
% F ... |
function result = apply(fn, X)
result = cellfun(fn, num2cell(X', 1))';
end |
function [ UPDOWN,ratehist,durhist ] = DOWNdetection( spikes,varargin )
%mean, CV, UP/DOWN times,
%option: try multiple rate bins, thresholds
%
%OPTIONS
% 'threshold' Rate threshold - below this is DOWN state (default: 0.5Hz)
% 'binsize' (Gaussian) Binning window for calculating rate (default: 25 ms)
% ... |
function [Q] = ModReceive(ser,MODid,q)
Q = q;
qA = [1 0 0 0];
qB = [1 0 0 0];
qC = [1 0 0 0];
qD = [1 0 0 0];
qE = [1 0 0 0];
flg = 0;
i = 1;
datamodified = ["0","0","0","0","0";
"0","0","0","0","0";
"0","0","0","0","0";
"0","0","0","0","0";
"0","0","0"... |
function [avg, stdev] = stat( x ) % function definition line
% STATS Mean and standard deviation % H1 line
% Returns mean (avg) and standard % Help text
% deviation (stdev) of the data in the
% vector x, using Matlab functions
avg = mean(x);
stdev = std(x)... |
function w=read_wrfout_tign(f,ts)
% w=read_wrfout_tign(f)
% w=read_wrfout_tign(f,timestep)
% read variables from wrfout f for detect_fit_level2 and cycles
% in
% f file name
% ts time step (string, optional). Read last time step if not given.
%
if f(end) == 't'
fpri... |
function sVBM_plot_timeseries(scans_to_process, metric)
%sVBM_plot_timeseries - generate various time series plots of change
%structure
%
% Syntax: sVBM_plot_timeseries(plottype)
%
% Inputs: plottype:
%
%
% Outputs: generates images in folder
%
% Other m-files required:
% Subfunctions:
%
% MAT-files required:
%
% See... |
function varargout = EXTMP(varargin)
% EXTMP MATLAB code for EXTMP.fig
% EXTMP, by itself, creates a new EXTMP or raises the existing
% singleton*.
%
% H = EXTMP returns the handle to a new EXTMP or the handle to
% the existing singleton*.
%
% EXTMP('CALLBACK',hObject,eventData,handles,...) cal... |
function table3
close all; clc
file_prefix = '../../RESULTS/selected_features_';
file_sufix = {'4_public', '8_public', '4_ohca', '8_ohca'};
ddbb_name = {'PUBLIC-4s', 'PUBLIC-8s', 'OHCA-4s', 'OHCA-8s'};
alg_name = {'BSTsel','L1-LRsel'};
for l = 1:length(file_sufix),
file = [file_prefix file_sufix{l}];
lo... |
% Timothy Smith
% Fourier Methods Frequency Plots
% FFt menu span=100 kHz, Linewidth=250 Hz , acq time=4ms
% FFt menu span=12.5 kHz, Linewidth=31.25 Hz , acq time=32ms
figure
% FFt menu span=100 kHz, Linewidth=250 Hz , acq time=4ms
subplot(2,1,1)
plot(Frequency_2,Voltage_2,'c')
xlabel('Frequency')
ylabel('Voltage')
... |
%% Intro
% Test Case for MyModeStringSolver
clc
clear
[filepath,~,~] = fileparts(pwd);
newpath = [filepath,'\Function_Packages'];
addpath(newpath);
Intro();
%% Input data
Dat = importfile('assasd.csv');
Dat_arr = table2array(Dat);
BLK_Size = str2num(Dat_arr(2,1)); % Blocksize constant
fs ... |
# Octave based linear regression reference data generation.
noise = 1;
slope = (round(100 * rand())-50) / 10;
offset = (round(100 * rand())-50) / 10;
n = 5 + abs(round(90 * rand()));
x = [0:n]' / 10;
y = round((slope * x + offset + (noise * randn(size(x)))) * 1e2) / 1e2;
c = [ones(length(x),1),x] \ y;
disp(jsonencode... |
function [index]=find_minimum_assign(distance,clusters)
%% find minimum
value_min=min(distance);
%% assign to a center of a cluster
index=find(distance==value_min);
if(length(index)>1)
index=randi(length(index),1,1);
end
%% checking before sending
if (index==0 || index>... |
% function [ AERstream ] = aer_t( vid )
clear AERstream* ONevents* OFFevents* ii jj
tic;
sizeVid = size(st_vid);
bits_row = length(dec2bin(sizeVid(1)));
bits_col = length(dec2bin(sizeVid(2)));
bits = max([bits_row bits_col 8]);
off = 127;
on = 255;
kk = 1;
for ii = 1:sizeVid(3)
[ONeventsrow, ONeventscol] = find(st_... |
%%
% Manually got the pixel position from R & L pictures
% by Frost Xu
% @ KAUST, VCC
%
clc; clear; close all;
addpath('C:\Users\xum\Downloads\toolbox_calib\TOOLBOX_calib')
load('inPara.mat')
SR = imread('SR.bmp');
% SL_P = imread('SL_P.bmp');
SL = imread('SL.bmp');
% imPart = rgb2gray(SL_P);
% imWhole = r... |
function [Nmodel] = singleexp(p, N0, t)
% This function is given a growth rate parameter p (1) and an initial cell
% number N0 and returns the corresponding model cell numbers
% model
% N(t) = N_0 * exp(g*t)
Nmodel = N0.* exp((p(1)*t));
end |
function [Label, D_atom, dist, counter] = eNN_Loop_Current(obj,pts,epsilon,upperbound)
%enn_loop_current: epsilon nearest neighbors search with a loop
% input:
% pts: enquery points, dxN, with d points of dimension N
% epsilon: error of eNN search
% upperbound: current estimat... |
function brant_check_paths
% check and update paths of brant and it's dependent packages
brant_path = fileparts(which(mfilename));
path_file_brant = fullfile(brant_path, 'config_paths', 'brant_paths.txt');
path_file_spm = fullfile(brant_path, 'config_paths', 'spm_paths.txt');
hid_path_file_spm = fullfile(brant_path, ... |
function [gtr1,gtr2,gav1,gav2] = ns_gave_old(subj,condition1,condition2)
% par.avdir
avdir='/neurospin/meg/meg_tmp/2010_auditorygaze_Lukasz/mAgaze/ft_data/av_data/';
for n=1:length(subj)
if subj(n)<10
subjprefix = 's0';
else
subjprefix = 's';
end;
c1{n}=getfield(load([avdir subjprefix... |
%% convert granger
import dsp2.util.cluster.tmp_write;
dsp2.cluster.init();
conf = dsp2.config.load();
load_path = fullfile( conf.PATHS.analyses, 'granger' );
base_fname = 'converted';
files_are = 'days';
tmp_fname = 'convert.txt';
tmp_write( '-clear', tmp_fname );
epochs = dsp2.util.general.dirnames( load_path, '... |
function pd = mvnormpdf(X,MU,K,dolog)
if nargin<4, dolog=0; end
% MVNORMPDF
% - calculates the density at X of the mutivariate normal
% distribution. I.e. N(X | MU,K)
% - inputs X and MU are expected to be column/row vectors
% - K is the covariance matrix (nonsingular)
[N,M] = size(X);
if M>1,
... |
function calibratedReading=calibrateReading(measuredReading, transmitterID, receiverID)
%calibratedReading=getCalibratingReading(measuredReading)
%
%This function uses the calibration information for your transmitter and receiver on the measured Reading
global TOF_CALIBRATION
if length(TOF_CALIBRATION.transmitterCoef... |
speech_vector = audioread('speech.au');
X = double(speech_vector);
Y2 = Uquant(X,2^7);
E = Y2 - X;
Y3 = Y2 .^ 2;
E2 = E .^ 2;
Py = (1/length(Y3))*sum(Y3);
Pe = (1/length(E2))*sum(E2);
PSNR7bs = Py / Pe
Y2 = Uquant(X,2^4);
E = Y2 - X;
Y3 = Y2 .^ 2;
E2 = E .^ 2;
Py = (1/length(Y3))*sum(Y3);
Pe = (1/length(E2))*sum(E2);... |
clear;
clc;
load('~/Downloads/data_matlab/data1.mat');
%% |
function car = find_Car(blob_Cents, tri_Combs, A, P, parameters)
% Area and Perimeter range
A_min = parameters(1);
A_max = parameters(2);
P_min = parameters(3);
P_max = parameters(4);
% comparing triangles to expected range
car = blob_Cents(tri_Combs(( (A_min<=A<=A_max) & (P_min<=P<=P_max) ), :)... |
function display_results(ArgsForDisplay)
[fixed, R_fixed, moving, R_moving, reg_moving, R_reg_moving, roi, R_roi, reg_roi, R_reg_roi, visit_nb, rawmod_name] = ArgsForDisplay{:};
% 2D registration results
if size(fixed, 3) == 1
% Change the contrast of images if necessary
% fixed = imadjust(fixed, stretchlim(f... |
function [backIm backStack usable] = calculateBackgroundFromFilelist_thermal(filelist, nvid, qntl, frameNumber)
% Inputs
% filelist - list of video files to calculate a collective background
% image for
%
% nvid - how many videos to sample
%
% frameNumber - what frame number to choose from vid?
%
% qntl - quant... |
function result = CalculateC_YF(alpha,beta)
%机身侧力系数C_YF
% alpha:机身迎角
% beta:机身侧滑角
result = 29.3616*sin(alpha) - 43.468*sin(2*alpha) - 81.8924*sin(alpha)^2 - 84.1469*cos(alpha) ...
- 0.821406*1e-1*beta - 3.00102*sin(4*beta) + 0.323477*beta^2 + 85.3496;
end
|
% Copyright 2014
%
% Licensed under the Apache License, Version 2.0 (the "License");
% you may not use this file except in compliance with the License.
% You may obtain a copy of the License at
%
% http://www.apache.org/licenses/LICENSE-2.0
%
% Unless required by applicable law or agreed to in writin... |
function [Percentile_Values,BWMask,Seg] = PercentileThresholding(f,I,Channels,Percentile_Thresholds)
%% Determine the intensity values of the percentile ranges provided in Percentile_Thresholds %%
Percentile_Values.Lower(1,1) = prctile(I.Ch1,Percentile_Thresholds.Lower(1,1),'all');
Percentile_Values.Upper(1,1) = p... |
a = 0.975928955078125; % a optimal en E : t_f
a = 0.930468750000000; % a optimal en E : moyenne
[x, y] = gen_traj(a);
dxd = derivate_pp(x);
dyd = derivate_pp(y);
[psil, psir] = mov_interpolation(4, dxd, dyd);
A = zeros(40, 1);
G = 0.8:0.005:1;
for i = 1:41
A(i) = mean_error(G(i));
fprintf('a=%f -> E''=%f\n', G(i... |
run MPCC_generalpolicy.m;
run MPCC_generalpolicy2.m;
%
% % asa
% i=0;
% while 1<2
% display('Iterating, Errortol');
% display(cos(i)*1e-2);
% i=i+1e-1; pause(0.8)
% end |
% Equation pour le système de Lorenz
% **********************************
function out = equationLorenz(t,x) %#ok<INUSL>
global sigma r b;
% sigma = 10; r = 28; b = 8/3;
out = zeros(3,1);
out(1) = sigma*(x(2) - x(1));
out(2) = r*x(1) - x(2) - x(1)*x(3);
out(3) = x(1)*x(2) - b*x(3);
end |
function value = interpolate_in_time(time, variable)
time= time.*8;
before = floor(time)+1;
fraction = time - (before-1);
value = (1-fraction) .* variable(before) + fraction .* variable(before+1); |
function playTexture_PiecewiseRetinotopy
%play piecewise closed contour stimuli for V4 GA
global Mstate screenPTR screenNum loopTrial
global daq %Created in makeGratingTexture
global Stxtr %Created in makeSyncTexture
global vSyncState %ventilator sync
Pstruct = getParamStruct;
%get s... |
function y=beside(x1,x2)
%BESIDE Arrange two images beside each other.
% Y = BESIDE(X1, X2) puts X1 and X2 beside each other in Y.
% Y is padded with zeros as necessary and the images are
% separated by a blank column.
% work out size of Y
[m1,n1]=size(x1);
[m2,n2]=size(x2);
m = max(m1,m2);
y=zeros(m,n... |
% calculate rate of OH + C2HCl3 -> products
% Updated 6/10/15
% Based on MCM v. 3.3
% rate = kOHC2HCl3
%
function j = kOHC2HCl3(T,M)
j = 3.0e-13.*exp(565../T); |
function lib = rename(lib,name)
% RENAME(LIB,NAME) renames the LIB to NAME.
lib.name = name;
lib.libname = name;
|
function[H] = homographyEstimate(xVect1,yVect1,xIncVect1,yIncVect1)
xInc1=xIncVect1(1);
xInc2=xIncVect1(2);
xInc3=xIncVect1(3);
xInc4=xIncVect1(4);
yInc1=yIncVect1(1);
yInc2=yIncVect1(2);
yInc3=yIncVect1(3);
yInc4=yIncVect1(4);
x1=xVect1(1);
x2=xVect1(2);
x3=xVect1(3);
x4=xVect1(4);
y1=yVect1(1);
y2=yVect1(2);
y3=y... |
function [atrVal] = atr( HighPrice, LowPrice, ClosePrice, nDay)
% average true range
% 默认回溯天数 nDay =14
% daniel 2013/4/16
% 预处理
if ~exist('nDay','var'), nDay = 14; end
[nPeriod, nAsset] = size(HighPrice);
atrVal = nan(nPeriod, nAsset);
% 计算步
hml = HighPrice-LowPrice;
hmc = [zeros(1,nAsset); abs(HighPrice(2:nPeriod,:... |
%function Wavelet = PulseSegmenter(cmhSong,cmhNoise,a, b, c, d, e, f, g, h, i, Fs)
function Wavelet = PulseSegmenter(cmhSong,cmhNoise, pWid, minIPI, thresh, Fs)
%========PARAMETERS=================
%segParams.fc = a; % frequencies examined. These will be converted to CWT scales later on.
%segParams.DoGwvlt = b; % Deri... |
function y = lasso_binary_clustering(X,tau,lambda)
ns = size(X,2);
y = zeros(1,ns);
ind = randperm(ns,1);
lambda=1/lambda;
cost = lasso_cost(X(:,ind),X, lambda);
[cost cI] = sort(cost);
E = cumsum(cost);
E = E./E(end);
y(cI(1:min(find(E > tau)))) = 1;
|
function [tlist, impres, tstep, tspan, err, errmsg] = spimpres_1208a(freqlisti, sparam)
% (c) Jianhua Zhou, 2012
%% Description: generates impulse response of an S-parameter element.
% input variables
% freqlisti(double): list of frequencies in column.
% Requirements include:
% (1) must contain... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.