text stringlengths 8 6.12M |
|---|
function IsCurtain = Arduino()
%Need to install add-on "MATLAB Support Package for Arduino Hardware"
%actual distance from IR to IR block is 32cm with the hole, robot base,
%hole config. However, there is error that causes the sensor to output
%between 30 and 34cm at non-intrusion. Recieving a value higher than 34c... |
%生成n个随机样本点
clear;
a = 2; b = 3; n = 100;
x = linspace(0,15,n);
y = a*x + b;
mu = 0; sigma = 1;
datay = y;
for i=1:n*0.5
datay(i) = y(i) + 6*rand;
end
plot(x, datay,'b.');
hold on;
%直接用最小二乘进行拟合
p = polyfit(x, datay, 1);
s=polyval(p,x);
plot(x,s,'r');
hold on;
%用RANSAC方法进行拟合
k = 800; t = 0.1; d = n * 0.95;
flag = 0;
... |
function [AudioMatrix, auditorySampleIndex] = AnimatePinkNoisyRipple(AudioMatrix, PinkNoiseMatrix, Frequency1, Frequency2, Coherence, Duration, SampleRate, auditorySampleIndex)
%Generates a sine wave, hides it in white noise and converts to audio WAV file. Also adds 5ms taper function
% Frquency in Hz
% Duration in... |
%- RWP: Random Way Point
%- CVBMM: Coverage-based
%- CNBMM: Connectivity-based
%- ABMM: Alpha-based
%- Mobility Prediction Clustering
%- Highest-Degree Clustering
%- Our Approach
% coverage
lg = {'Random Waypoint', 'Coverage-based', ...
'Connectivity-based', 'Alpha-based', 'Our Approach'};
legend(lg... |
% ADVISOR data file: TX_ZF4HP590.m
%
% Data source: Gear Ratios from http://www.hkid.com/people/chuk/gearbox.htm
% and the 1998 Diesel Truck Index
%
%
% Data confirmation: Not confirmed
%
% Notes:
% This file defines the ZF 4-speed 4HP590 automatic transmission but treated as
% a conventional transmission in the model... |
function properties = set_properties_live(properties,gp,sp,ap,cp)
% Updating general params
properties.general_params.bcv_workspace.BCV_input_dir = gp.BCV_input_dir;
properties.general_params.bcv_workspace.BCV_work_dir = gp.BCV_work_dir;
properties.general_params.analysis_level.value = gp... |
function [costOptimals,EBOoptimals] = dynamic(EBOArray, costArray, nLRU)
fID = fopen("files/dynOutput.txt", "w");
fprintf(fID, "1\t2\t3\t4\t5\t6\t7\t8\t9\tEBO\tCost\n\n");
maxBudget = 500;
% currentStates holds all states that are being considered at a given
% time, each row being a state... |
N0 = 10;
syms n;
k = -10:1:10;
x = 1;
w = (2*pi)/N0;
T = x*(exp(-1i*k*w*n));
a = (1/N0)*(symsum(T, n, 0, 4));
stem(k,a);
title('Signal of a');
figure;
stem(k,abs(a));
figure;
title('Magnitude spectrum of a');
stem(k,angle(a));
%Since the magnitude of a, has sine dependencies, the graph of a will show
%the same, as is ... |
if nargin == 0
SelectedPath = spm_select(1,'dir');
end
cd(SelectedPath)
if exist('AnalysisParameters.mat')
load AnalysisParameters
else
errordlg('this folder does not have the required AnalysticParameters.mat file');
end
cd('Results')
% Check to see if the process is finished
F = dir('Results_*.mat');
NJobS... |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% init() %
% %
% Set initial parameters for part1.slx and part2.slx %... |
%% Finding neighborhoods which follows to given node
% Input:
% 1. mc - conectivity matrix
% 2. node - given node
% Output:
% 1. neigh_nodes - node numbers
function [neigh_nodes] = neigh_search(mc,node)
count = 0;
neigh_nodes = zeros(0,1);
for i = 1:size(mc,1)
if((mc(i, node) == 1) && (n... |
classdef nlpproblem < model.nlpmodel
%NLPPROBLEM Implements nlpmodel with user written functions
properties
fobj_loc
gobj_loc
hobj_loc
fcon_loc
gcon_loc
gconprod_loc
hcon_loc
hlag_loc
hconprod_loc
hlagprod_loc
ghivprod_loc
end
methods
function self... |
all_data = [Health Economy];
sizes = size(all_data);
indices = randsample(1:157, 157);
X_data = all_data(indices,:);
Y_data = HappinessScore(indices, :);
N = 157;
N_teach = 130;
N_test = 27;
bootstrap_size = 10;
X_teach = X_data(1:N_teach,:);
X_test = X_data(N_teach+1:end,:);
Y_teach = Y_data(1:N_teach,:);
Y_test = Y... |
function [out1,out2] = mywwavf(LB,UB,N,wname)
%MYWWAVF MyWAVE wavelet.
% [PSI,X] = MYWWAVF(LB,UB,N,W) returns values of the wavelet
% W in the family Myw, on an N point regular grid in
% the interval [LB,UB].
% The valid values for W are: 'myw3', 'myw4', 'myw5', 'myw6'.
%
% Output arguments are the wavelet f... |
function reference_points=get_reference_points(use_meters)
% construct reference points and convert them to feet
% REVISIT: need more accurate coordinates
right_stripe = [ 4 2.5; 6 3; 7.4 -2.3; 5.4 -2.8 ];
left_stripe = [ -right_stripe(:, 1)'; right_stripe(:, 2)']';
reference_points = [ right_stripe; left_stripe ] / 1... |
% generate tcm diagnostic plots
figure('position',[1010 42 774 943]);
subplot(221); plot(w,DCM.xY.y{1},':',w,y{1});
title('Data & Model - Fit');
xlabel('Frequency (Hz)');ylabel('PSD');
grid on;
subplot(222); plot(w,squeeze(l{1}.weighted(1,:,:)),'linewidth',2);
title('Principal (contributing)... |
function [means, vars, ci_dn, ci_up] = CS5320_question_answer_plot2()
% produce error
% On input:
% No input. All required parameters are specified within the function
% On output:
% means(1X10): mean error in the point locations in the image with variance
% in parameter ranging from 0.1 to 1
% variance (1... |
%% odd numbers
% file: q1a.m
%
% by Nathaniel Chang
% Created: 16/03/2021
% last edited: 16/03/2021
% programing (MATLAB and C) Semester 1
% intializing values
n = 0;
vector_odd = [1];
% asking user for input
n = input("how many od numbers do you want?: ");
n = n-1;
% creating the odd numbers
for i = [1:n]
vect... |
function [ c, ceq ] = func( u, X_0, X_f, dt )
N = length(u);
X_calc = zeros(2,N);
X_calc(:,1) = X_0;
for i = 2:N
X_calc(:,i) = X_calc(:,i-1)+ ...
dt*( [X_calc(2,i-1) ; u(1,i-1) - X_calc(2,i-1) - sin(X_calc(1,i-1)) ] );
end
ceq = X_f - X_calc(:,end);
c=[];
end
|
clear;close all;
%folder containing data (a sequence of jpg images)
dirname = '../data/DARPA_VIVID/eg_test01/egtest01/';
%find the images, initialize some variables
dirlist = dir(sprintf('%s/*.jpg', dirname));
nframes = numel(dirlist);
startFrame = 1;
margin.X=20;
margin.Y=30;
current_frame=[];
previous_frame=[];
%set ... |
function [hl, hr]=luxusfft(Hl,Hr,n,Mmean)
%function [hl, hr]=luxusfft(H,n,Mmean)
epsilon=1E-8;
Hl=fade(Hl,171,271,839,939);
Hr=fade(Hr,171,271,839,939);
index=find(Hr==0); Hr(index)=ones(size(index))*epsilon;
index=find(Hl==0); Hl(index)=ones(size(index))*epsilon;
hl=rifft(Hl);
hr=rifft(Hr);
[dl,tl]=... |
function [enf, time] = extractAud(y,fs)
[ynew, fsnew] = bandpass_process_nharmonics(y, fs, 60, 0.1, 4, 0.5);
freqmat = quad_interpolate_multipeak(ynew, fsnew, 10000, 9000, 40000, 15);
path = leastcostENF(freqmat');
time = [1:length(path)];
enf = path;
end
|
function varargout = HMPdetector(varargin)
% *GUI* HMPdetector
%
% -------------------------------------------------------------------------
% Author: Barbara Bruno (dept. DIBRIS, University of Genova, ITALY)
%
% This code is the implementation of the algorithms described in the
% papers "Human motion modeling and reco... |
clc; clear all; close all;
inputfile = 'fancycar';
inputext = '.jpg';
input = [inputfile,inputext];
input_img = imread(input);
[rows, columns, numberOfColorChannels] = size(input_img);
if numberOfColorChannels == 3
input_img = rgb2gray(input_img);
end
array_hist = imhist(input_img); % probability from the his... |
% Try to make the source (transducer) a single pulse 05/11/2019
% instead of a continuous pulse, want to achieve this to see
% if we can perceive the reflected wave
% ATTEMPT 2 (using kspaceFirstOrder --> transducer)
close all
clear all
% create computational grid
Nx = 128; % number of grid poi... |
%% Opdracht 5
% Gebruik een for-lus om de getallen
% tussen -5 en 5 af te drukken in het Command Window.
|
function dy = seir_ode(t,y,p,usrfn)
dy = zeros(4,1);
beta = p(3);
if !strcmp(usrfn,"NONE"), beta=beta*user_functions(t,p(6:end),usrfn,y(3)/p(2)); end
dy(1) = -beta*y(1)*y(3)/p(2); %dS/dt = -beta*S*I/N
dy(2) = beta*y(1)*y(3)/p(2)-p(5)*y(2); %dE/dt = beta*S*I/N - kappa*E... |
if ~exist(fullfile(files_path, 'postprocessed_data', 'behavioral_model_fits.mat'), 'file')
% If the model fits do not exist, re-run them
fig1_fit_models
end
if ~exist(fullfile(files_path, 'figure_panels', 'Fig2_S2_individual_rat_glms'), 'dir')
mkdir(fullfile(files_path, 'figure_panels', 'Fig2_S2_individua... |
function blank_hit(Bx,By,size,board)
global a0 a1 a2 a3 a4 a5 a6 a7 a8 aflag amine aempty
disp([Bx By])
drawnow
if Bx>=1 & Bx<=size & By>=1 & By<=size
if board{By,Bx}{1,1}==1
return
end
if board{By,Bx}{1,1}==0
image_creation(board{By,Bx}{1,2},Bx,By,size);
board{By,Bx}... |
o
med_age = [29 45 55 65 75 85]';
hr_age_sex = [.05 .27 1 2.61 7.61 26.27]';
hr_full = [.07 .31 1 2.09 4.77 12.64]';
ln_hr_age_sex = log(hr_age_sex);
ln_hr_full = log(hr_full);
age = [18:100]';
%% use a polynomial interpolation since spline fails on the endpoints
fit_age_sex = fit(med_age, ln_hr_age_sex, 'poly... |
function xtickfrq2per(H,Fmt)
try
H; %#ok<VUNUS>
catch
H = gca( );
end
try
Fmt; %#ok<VUNUS>
catch
Fmt = '%.1f';
end
%--------------------------------------------------------------------------
xTick = 2*pi./get(H,'xtick');
n = length(xTick);
xTickLabel = cell(1,n);
for i = 1 : n
xTickLabel{i} = s... |
function MS=symplectify(M)
%symplectify makes a matrix more symplectic
%follow Healy algorithm as described by McKay (2006)
%BNL-75461-2006-CP
J=jmat(3);
V=J*(eye(6)-M)*inv(eye(6)+M);
%V should be almost symmetric. Replace with symmetrized version.
W=(V+V')/2;
%Now reconstruct M from VS
MS=(eye(6)+J*W)*inv(eye(6... |
%% This code process the point cloud to become the elevation grid map
% Use elevstion grid to find the best path using shortest weighted algorithm
clear variables; clc; close all;
%% parameter settings
enable_point_cloud = 0; % plot 3D points distribution using fscatter3
enable_surf_plot = 1;
% intensity_thresho... |
clear all;
close all;
%load('D:\Leo\0229\merge\merge_0224_HMM_UR_DL_G2.5_5min_Q100_6.5mW.mat')
load('merge_0224_HMM_UL_DR_G4.5_5min_Q100_6.5mW.mat')
%load('merge_0224_OUsmooth_RL_G4.5_5min_Q100_6.5mW_1Hz.mat')
fps =60;
x = bin_pos(1:end);
v = finite_diff(x ,4);
BinningSpike = zeros(60,length(diode_BT));
analyze_spikes... |
function amdarData = filterByIndex(amdarData,index)
%FILTERBYINDEX Prunes the data based on the index.
% We use a dynamic fields approach to handle arbitrary field names.
%
%SYNTAX:
% amdarData = Amdar.filterByIndex(amdarData, amdarData.altitude > 2000);
%
%INPUTS:
% amdarData - structure containing Amdar data.
% ... |
% coordinates of points
xp = [0; 21; 30]
yp = [0; 55; 75]
% set up equations
n = rows(xp);
A = [ones(n,1), xp, xp .^ 2];
l = yp;
x = A \ l
printf('Check\n')
polyval(flipud(x), xp) -yp
|
function [ win_row, win_col, dist_mat ] = findWinningNode( weights, inp_mat, nInpDims )
%%% Find winning node
% this function calculates two things. first is the winning node, with is
% the node that is the closest (in a euclidean sense) to the input.
% ALSO, the function calculates dist_mat, which is the distance of ... |
function s = print_nfm(m)
%PRINT_NFM Summary of this function goes here
% Detailed explanation goes here
s = cell(size(m,1),1);
%m = m.*4;
for i=1:size(m,1)
row = "";
for j=1:size(m,2)
cel = strcat("(",num2str(m(i,j,1),2),",",num2str(m(i,j,2),2),"),");
row = strcat(row,cel);
end
s{i} =... |
classdef NdgBottomHaloEdge3d < NdgBottomInnerEdge3d
%NDGBOTTOMHALOEDGE3D Summary of this class goes here
% Detailed explanation goes here
properties ( SetAccess = protected )
%> edge type
ftype
end
methods
function obj = NdgBottomHaloEdge3d( meshUnion3d, meshId )
... |
%load all
%folder structure (all:(deploy, detect, ensemble, locs))
%all: .m files
%detect: .mat input files
%locs: .mat loc input files
%all: array_struct
%sourcemaps: 4 sourcemaps dets, depl, ens, locs
%start: in root folder
%execute loadall.mat
%end load 14 deploys, 4 ensembles, locs for number of days... |
function gen_dyn_boom_leg
% generate the dynamics for the hopping leg with boom
% Author: Yanran Ding and Joćo Ramos
% Last modified: 2020/09
clear
%% --- define symbols ---
syms q1 q2 q3 q4 real % joint angle
syms dq1 dq2 dq3 dq4 real % joint velocity
syms HB LB DB LH DK LK real % linkage... |
# -*- octave -*-
# $Id$
function [a,dns]=ana_efr
stns = {"L2.129100_EFR_Mainflingen", ...
"L2.135600_EFR_Lakihegy", ...
"L2.139000_EFR_Burg"};
for year=2013
for i=1:length(stns)-1
[a,dns] = proc_year(stns{i}, year);
save(sprintf("%d_%s.mat", year, stns{i}), "a", "dns");
endfor
endfor
... |
clc
clear all
close all
Path='/home/omar/PhD/Runs/dataExtraction/uncontroledChannel';
fileNameIntial='ux';
nTime=38500;
dt=0.005;
% ========== Main Grid Size =================
nx=128;
ny=129;
nz=84;
Lx=4*pi;
Ly=2;
Lz=4/3*pi;
dx=Lx/(nx-1);
dz=Lz/(nz-1);
y=load([Path,'/','yp.dat']);
dy=y(2)-y(1);
%#######################... |
function z = f(x,y)
z = x.^3+(y.*exp(x))/(x+1);
end |
% Plot Spatial Frequency vs. Eccentricity for Subj001
%% Setup mrVista
mrvDir = '/Volumes/server/Projects/SOC/data/fMRI_CBI/wl_subj001_2016_02_17';
cd(mrvDir);
vw = mrVista;
gray = mrVista('3');
%% Get ROIs
% These are found in
% Projects/SOC/data/fMRI_CBI/wl_subj022_2015_06_19/Inplane/ROIs,
% choose the ones that a... |
function y_predict = predict3_bp(X_train, X_predict, basedNum, predictNum, s2, lambda, alpha, max_iter)
%% 使用神经网络根据前14天的数据预测后两天的数据,以basedNum个t时刻前数据预测t时刻后第predictNum个数据
%% X_train:为前14天训练样本,一行为一天的数据 X_predict:为后两天的原始数据,一行为一天 basedNum:依据的数据个数
%% s2为第二层节点数,lambda为参数,alpha为学习率,max_iter为迭代次数
%% y_predict:一行为一天的数据
%% 开始预... |
function u = FastPoisson(n1,type1,n2,type2,b)
% function u = FastPoisson(n1,type1,n2,type2,b)
% Fast Poisson solver that can handle Dirichlet(D) and Neumann(N) boundary
% conditions
% n1 = positive integer
% type1 = 'DD', 'DN', 'ND', 'NN'
% n2 = positive integer
% type2 = 'DD', 'DN', 'ND', 'NN'
% b (n1*n2x... |
function [ceq,gradceq]=hipVelCon(x,p)
% the start and end velocity are the same
% direction
% c_cell = cellfun(@(x)hip_x_vel(x,p),num2cell(x,1));
% c = cell2mat(c_cell);
% gradc_cell = cellfun(@(x)dHip_x_vel(x,p),num2cell(x,1));
% gradc = cell2mat(gradc_cell);
q1_1 = x(:,1);
q1_2 = x(:,2);
q1 = (q1_1+q1_2)/2;
dq1 = (... |
%Programa de resolucion del modelo de Cournot con informacion asimetrica y distribucion continua de precios
clear;
clc;
a=40;
cost=10;
sigma=5;
F = makedist('normal','mu',cost,'sigma',sigma);
FT = truncate(F,3,7);
Ndraws=10000;
c_est=random(F,Ndraws,1);
q_A=1/3*(a-2*cost+mean(c_est));
q_B=zeros(Ndraws,1);
... |
function practical_output = rbfnet(ran, input)
[~, input_count] = size(input);
if (ran.hidden_dimension == 0)
practical_output = repmat(ran.Bout, 1, input_count);
else
spread_mat = repmat(ran.spread_constants, 1, input_count);
overall_distance = dist(ran.unit_centers', input);
activation = radb... |
function [ pdf ] = gaussianND(X, Mu, Sigma)
% Calculate multivariate Gaussian
% X - Vector of data points
% Mu - Mean Vector
% Sigma - Covariance matrix
n = size(X, 2);
meanDiff = bsxfun(@minus, X, Mu);
pdf = 1 / sqrt((2*pi)^n * det(Sigma)) * ...
exp(-1/2 * sum((meanDiff * inv(Sigma) .* meanDiff), 2));
en... |
function [ionop cxi0 ambi]= iono(ionop,cxi0,prnlist,elvlist, ...
ambi,l1,l2,p1,p2,cst,cpsd,otpt12,otptri,cdate,ocdate,ipp,recllh)
%
% Function iono
% =============
%
% This function computes the IONO delay using L1/L2.
%
% Sintax
% ======
%
% [ionop cxi0 ambi]= iono(ionop,cxi0,prnlist,elvlis... |
close all; clear; clc;
%% Problem 2
% Problem 2 (a)
x1 = 1; x2 = 0; x3 = 0; x4 = 0; x5 = 0;
x = [x1, x2, x3, x4, x5]';
A = hilb(5);
leftA = sum( abs(A*x) );
rightA = max( sum( abs(A) ) );
% Problem 2 (b)
y1 = 0; y2 = 0; y3 = 0; y4 = 1; y5 = 0;
y = [y1, y2, y3, y4, y5]';
B = inv(A);
leftB = sum( abs(B*y) );
... |
% Num issues matched
path2data = '.\data\TAQ';
master = load(fullfile(path2data, 'master'), '-mat');
master = addPermno(master.mst);
[dates,~,subs] = unique(master.Date);
nobs = master.To-master.From+1;
tot = accumarray(subs,nobs);
idx = master.Permno~=0;
matched = accumarr... |
function [ feat ] = get_cnn_activations( im, net, subWins, layers, varargin)
%GET_CNN_FEATURE Get CNN activation responses for im
% im::
% image matrix, #channels (size(im,3)) must be compatible with net
% 0~255
% net::
% cnn model structure
% subWins:: [0; 1; 0; 1; 0]
% see get_augmenta... |
%1998年全国大学生数学建模竞赛A题:收益与风险 有效投资曲线
%参看《数学的实践与认识》1999年第一期,p39-42
%
%另见 jm98a1,jm982,jm983,jm983fun
clear;close;
%问题一有效投资曲线
n=4;
r=[28 21 23 25 5]'/100;
q=[2.5 1.5 5.5 2.6 0]'/100;
p=[1 2 4.5 6.5 0]'/100;
u=[103 198 52 40 100]';
subplot(1,2,1);
for lemda=linspace(0,1,300)
c=[(1-lemda)*(p-r);lemda];
A1=[(1... |
%Toughness scaling:
clear
close all
%syms Eprime Q0 t muprime Kprime
% Case 2 - Fig.1
eta=0.05;
Kc=2e6;
E=20e9;
nu=0.25;
Q0=0.015;
delta_gamma=1000*9.81;
mu=E/(2*(1+nu));
Vinjected=1.95;
nu=0.1;
% %% Oil in Gelatin - PyFrac sims - Fig 3/4
% nu = 0.5-1e-9 ; % Poisson's ratio [dmlss]... |
function [M_app]=fixed_point_approximation_tr(M,n,f)
% FIXED_POINT_APPROXIMATION Find a fixed-point representation
% [M_app]=fixed_point_approximation_tr(M,n,f) finds a truncation approximation
% to M in the [n,-f] (unsigned) fixed-point representation scheme.
%
% Jay L. Adams 2016
x=floor(M*2^f);
if((x>2^(n-1)-1)||(x... |
% Fundamental Plasma Functions - CGS gaussian units
%
% All inputs are in cgs gaussion units except Temperature which is in [eV]
% Use cgs2SI and SI2cgs to convert between Sia nd cgs units
% Use physicalConstants-SI and physicalConstants-cgs for values of
% constants
%
% EXAMPLE USAGE:
%
% B = SI2cgs(5,'Magnetic Field'... |
addpath(genpath('../utils'))
datafolder = '/Users/vickieye/Dropbox (MIT)/shadowImaging/edgeImaging/data/stereoDoor_Mar08';
datafolder = fullfile(datafolder, 'results');
pointstyle = {'b*', 'g*', 'c*', 'm*'};
linestyle = {'b', 'g', 'c', 'm'};
xmin = -2*20;
xmax = 3*20;
ymin = 0*20;
ymax = 7*20;
figure; hold on;
for i... |
A = [-0.2 0; 0 -0.8];
B = [1; 1];
C = [4/3 -1/3];
D = 0;
order=length(A);
co=rank(ctrb(A,B));
ob=rank(obsv(A,C));
|
path = [0 0; 7 7; 7 17; 0 27; -7 17; -7 7; 0 0; 0 0];
robotInitialLocation = path(1,:);
initialOrientation = 0;
robotCurrentPose = [robotInitialLocation initialOrientation]';
sampleTime = 0.001;
k = 1;
realPoseY = 0; realPoseX = 0;
realPoseY(k) = 0; realPoseX(k) = 0;
W1(k) = 0;
W2(k) = 0;
realW1 = 0; real... |
function closeAllExceptIllusionPaperFigures()
all_figs = findobj(0, 'type', 'figure');
for j=1:length(all_figs)
if ~(contains(all_figs(j).Name,'Figure ') || contains(all_figs(j).Name,'SuppFigure '))
close(all_figs(j))
end
end |
% AvgVar.m
% File defining one of the methods of class BallisticDataAnalysis.
% =========================================================================
% Write something short.
%
% plot average and variance of position
% =========================================================================
% modified (10/05/21)
... |
function [ret,startPos]=atsif_getdatastartbyteposition(source)
%AT_U32 ATSIF_GetDataStartBytePosition(ATSIF_DataSource _source, AT_32 * _ui_startPosition)
%
%
%Description : This function is used to retrieve the starting byte position of the source
% data in the SIF file.
% The data source... |
function palya = palyae(Pos,TrkPic,Trk)
%Ha nem pálya a Pos, akkor 1-et (true) ad vissza
%Trk a pálya színkódja. pl.: [99,99,99]
%Pos az aktuális pozíció pl.: [balról jobbra, fentről le]
if isnan(Pos(1)) || isnan(Pos(2)) || Pos(1)<0 || Pos(2)<0
palya = false;
else
if TrkPic(Pos(2),Pos(1)) == Trk
... |
clear all
close all
clc
avoid_overlap = 1;
avoid_borders = 1;
[xy_pairs, side_image_nm, n_of_particles] = ReadXYPairFromFile();
x_side_nm = side_image_nm;
y_side_nm = side_image_nm;
disp(['AFM particle density is ' num2str(n_of_particles/x_side_nm^2)])
average_diameter = 24;
r_step = 20;
n_of_generated_distributi... |
clear all;
close all;
target = 10;
PID_out = [];
state.p = 0.01;
state.i = 0.001;
state.d = 0;
state.target = 10;
state.initialized = false;
newData = 0;
for i =1:1000
if(i==564)
state.target = 17.65;
end
state = pidController(state,newData);
%plant
x = state.result;
y = x^3+0.76*x-9.45;
... |
close all
% Jim's first DRM
% num_stars = 350;
% total_obs = 450; % 350 + revisit top 100
% Jim's second DRM (actually the first computed using this code) based on hearsay (350 stars, 1000 observations)
% num_stars = 350;
% total_obs = num_pts*2.8; % 2 observations for all targets, plus 8 more (10 total) for top 10%... |
%{
psy.MovieStillStore (imported) # cached still frames from the movie
-> psy.MovieInfo
-----
%}
classdef MovieStillStore < dj.Relvar & dj.AutoPopulate
properties
popRel = psy.MovieInfo
end
methods(Access=protected)
function makeTuples(self, key)
self.insert(key);
... |
% batch template
global hm1;
hObject = hm1;
data_masterdir = GetCurrentDataDir();
range_fish = 8:13;
% M_ClusGroup = [2,2,2,2];
% M_Cluster = [1,1,1,1];
const_ClusGroup = 2;
const_Cluster = 1;
% M_fish_set = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2];
%%
for i = 1:length(range_fish),
i_fish = range_fish(i);
... |
% Calculate the expection based on the estimation result of the MCMC.
% E(x)=delta(x) times frequency of x
% Yuna Duan, April 15th
[Nrho,edgerho]=histcounts(rhoc(iUse));
[NdT,edgedT]=histcounts(dTc(iUse));
[NB,edgeB]=histcounts(Bc(iUse));
Erho=((edgerho(1:end-1)+edgerho(2:end))./2).*(Nrho./length(rhoc));
EdT=((edgedT... |
%%% CONFIGURATION FOR EXPORTING DATA %%%
% -- insert 2-second events
config(1).userinput = '%%PLACE-HOLDER%%';
% -- excise artifact from continuous data
config(2).userinput = '%EEG = eeg_eegrej(EEG, EEG.reject.rejmanualtimes); %drop for meantime, because likely to throw out shock epochs...';
% -- ICA-spatial-tempor... |
function [centroids, Y] = k_means( data, n, maxiter, thresh )
% performs k_means with random initialization
% on data with n centroids
N = size(data,1);
dim = size(data,2);
centroids = rand(dim,n)*max(max(data));
for k = 1:maxiter
% zeros will be ignored
points_belonging_to_centroids = zeros(N,n);
for i =... |
% This code was developed using R2016a Matlab version (windows platform)
% Compare the samples in test dataset with already obtained labels from CKSAAP_PhoglySite matlab software available at https://github.com/juzhe1120/Matlab_Software/blob/master/CKSAAP_PhoglySite_Matlab_Software.zip
% The result of this code is ... |
function [centerOfMassX, centerOfMassY] = ComputeCenterOfMass(A)
x = 1:size(A, 1); % Columns.
y = 1:size(A, 2); % Rows.
[X, Y] = meshgrid(x, y);
meanA = mean(A(:));
centerOfMassX = mean(A(:) .* X(:)) / meanA;
centerOfMassY = mean(A(:) .* Y(:)) / meanA;
end
|
function secant(x0,x1,f,tol)
% Input: x0 - initial guess
% x1 - second initial guess
% f - function handle of f(x)
% tol - tolerance
x_old0 = x0;
x_old1 = x1;
k = 1;
root = 2.0945514815423;
while( abs(x_old1-root)>tol )
x_next = x_old1 - f(x_old1)*(x_old1... |
function [Q, dQ] = thetaOptimization(theta,trainX,w,b,nonZero,distMat,Z,A,beta,T,repy)
% in this function, we need to calculate the function value of its gradient
% D is the parameter of d
ndata = size(trainX,1);
I = ones(ndata,1);
K = exp(-theta*theta*distMat); % Note that theta^2
w_nz = w(nonZero);
% %... |
clc
clearvars
close all
%% INPUTS
imageDirectory = './SampleData/ImageFiles'; % Image directory
outputDirectory = './SampleResults/'; % Directory for results
useImageNum = 300; % number of images to use for aligning images
cameraNum = 3; % number of cameras to align
imageString{1} = 'flea18'; % Identifying strin... |
%This function write files that are used in the property calculation :
% BoltzTraP calculation requires:
% CASE.struct : structure info
% CASE.energy : energy bands
% CASE.intrans : input parameters
% BoltzTraP.def : format file
% Dong Dong
% function writeProperty()
function Write_BoltzTraP(Ind_No)
global... |
function threshold_variant_maps(thresholds,SNRexclusion,absolutethresholds,outputdir,spatialmapslist,workbenchdir,surfdir,SNRpath)
%% Create binarized and unique ID files (and text files with filepaths and subject IDs) for each input variant map
%
% This function reads a text file in the format 'pathtofile subjectid' ... |
% FUNCTION: vectorAng
%Inverse tangen in degrees
% ---------
% Author: Dinithi Bamnuarachchi
% e-mail: mailtodinithi@gmail.com
% created the 02/07/2013.
% ---------
function theta = vectorAng(v1,v2)
ang2 = atand(v2(1,2)/v2(1,1));
ang1 = atand(v1(1,2)/v1(1,1));
ang2
ang1
%---
if(ang2 <0)
% theta... |
function fista = fista_cycle_fit(fista,fit_model,S_period)
N = length(fit_model);
fista.period_index = struct();
fista.cycle_num = cell(1,N);
fista.per_cycle_index = struct();
event_index=fista.X1_max;
for i =1:N
t_per_cycle = round(2*pi/fit_model{i}.b1);
fista.cycle_num{i} ... |
function Ave = average_structure(Struct)
%function Ave = average_structure(Struct)
% Average structured vector array
%
% Author: Dimitrios Pantazis
Ave = zeros(size(Struct{1}));
for i = 1:length(Struct)
Ave = Ave + Struct{i};
end
Ave = Ave/length(Struct);
|
function [X, Y, Z] = ned2xyz(refLat, refLong, refH, n, e, d)
% Convert north,east,down coordinates (labeled n, e, d) to ECEF
% coordinates. The reference point (phi, lambda, h) must be given.
% All distances are in meters
[Xr,Yr,Zr] = llh2xyz(refLat,refLong, refH); % location of reference point
phiP = atan2(... |
function cost = GetCost(res,ex,oldel,ja,dt,dtRef,L)
EL = 0:res:180;
oldel = find(EL<=oldel);
el = find(EL<=ja(2));
oldind = length(oldel);
ind = length(el);
dtRef = abs(oldind-ind)*dtRef;
Ref = zeros(4,length(EL));
JA = [ja(1),ja(3),ja(4),ja(6)];
ldt = L(5);
L = L(1:4);
switch ex
case 'abd'
Ref(1,:) = z... |
function calibrateWavenumberFunction(this,spectrum)
% Open the fitting figure
fitobj = spectraobjects.VIPAxaxis(2595,1.8405,63.2908,spectrum);
%s = load('C:\Users\bryce\Documents\GitHub\Combinator_v9\Spectrum Simulations\06_hit04.mat');
%s = load('H:\GitHub\Combinator_v9\Spectrum Simulations\06_hit04.mat');
... |
function [mxHyper, mxScore, scores] = cvHyperFitScores(X, Y, obj, scoreObj)
hypergrid = obj.hyperObj.hypergrid;
trials = tools.trainAndTestKFolds(X, Y, nan, obj.hyperObj.foldinds);
nfolds = numel(trials);
nhypers = size(hypergrid, 1);
scores = nan(nhypers, nfolds);
mus = cell(nhypers, nfold... |
function browseTroughData(source,eventdata,jump)
global panels gps fHandles metadata displayStatus const
% finding selected data serie
[p d]=selectedSensor();
if numel([p d])==2
type=panels(p).data(d).type;
ID=panels(p).data(d).ID;
% setting the right list dependin... |
function [quan]= quantize(im,QP)
[r, c] = size(im);
%Write Q matrix
Q=[16 11 10 16 24 40 51 61;
12 12 14 19 26 58 60 55;
14 13 16 24 40 57 69 56;
14 17 22 29 51 87 80 62;
18 22 37 56 68 109 103 77;
24 35 55 64 81 104 113 92;
49 64 78 87 103 121 120 101;
72 92 95 98 112 100 103 99;];
%Decide S v... |
function [Year, Month, Day] = Data_Format_Interpolation_fast_pa(file, base, ext)
%{
If formated as an .xlsx and or .csv file, the input data should be compiled
where each column represents:
Time | Depth | Latitude | Longitude | Temperature | Ax | Ay | Az |
If formatted as a mat file, each variable named as follows... |
function savePoints4mayavi(fileName, points)
% points 3*x
if ~isempty(points)
x = points(1,:);
y = points(2,:);
z = points(3,:);
if nargin == 2
save(fileName, 'x', 'y', 'z', '-v7');
else
save('~/p', 'x', 'y', 'z', '-v7');
end
disp('all the points: ');
disp(num... |
clc,clear
close all
clss = {'Insulator';
'Rotary_double_ear';
'Binaural_sleeve';
'Brace_sleeve';
'Steady_arm_base';
'Bracing_wire_hook';
'Double_sleeve_connector';
'Messenger_wire_base';
'Windproof_wire_ring';
'Insulator_base';
'Isoelectric_line';
'Brace_sleeve_screw'};
VOCopts = VOCinit();
filename = strcat('../VOCde... |
function saveSpinsImg(spins, fileName)
%remove boundary spins
S = spins(2:(end-1), 2:(end-1));
%convert to uint 255 scale
S = uint8(255.*S);
%write to file
imwrite(S, fileName)
end |
function [tspan, y] = heun_integrator(fun, tspan, y0)
%HEUN_INTEGRATOR Implementation of Heun's integration method
% INPUTS:
% fun: function that wants to be integrated
% tspan: interval of integration, that goes from intial time to the final
% time [t0 t1 t2 t3 ... tf] - it includes all timesteps
% y... |
% Transfer align simulation using real FOG/MEMS data under vehicular motion.
% See also test_align_transfer.
% Copyright(c) 2009-2021, by Gongmin Yan, All rights reserved.
% Northwestern Polytechnical University, Xi An, P.R.China
% 16/01/2021
glvs
psinstypedef('test_align_transfer_fog_mems_def');
load([glv.datapath,'t... |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% %%
%%% Written by Matthew Kontz %%
%%% ... |
%% ==== check trial distributions & initial examination of dataset (AL10) ==== %%
sNames = {
'DA',
'AL10',
'NH06',
'CT07',
'EH09',
'AW07',
'UB03',
'BT07',
'VH11',
'RN07',
'RS24',
'SMS05'};
age = [67,
62,
62,
64,
69,
63,
66,
71,
64,
66,
59,
75];
mean(age(2:end))
std(age(2:e... |
function [struc] = generateMesh(struc)
struc.spaceDim = 2; % physical spatial dimensions for cell (element)
struc.sideDim = 1; % physical spatial dimensions for subcell (side)
stru... |
function LBCN_anonimize_NKnew(fname)
% Function to anonimize edf file. It takes as inputs
% the name of the file (optional).
%--------------------------------------------------------------------------
%Written by J. Schrouff, LBCN, Stanford, 07/21/2015
% Inputs
if nargin<1 || isempty(fname)
fname = spm_select(in... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.