text stringlengths 8 6.12M |
|---|
% [ stacking_model, train_acc ] = stacking(part, X, Y, train_color, train_img_prob, train_cnn_feat, train_img, raw_tweets_train)
% INPUT
% X_train, Y_train - data to train different models
% X_test - data to test the models above, and the estimated Y_test_hat are
% used together with real label Y_test to train a ensemb... |
function values = RBES_get_values2(fact_id,slots)
values = cell(length(slots),1);
f = jess(['fact-id ' num2str(fact_id)]);
for i = 1:length(slots)
tmp = jess_value(f.getSlotValue(slots{i}));
if ischar(tmp)
% fprintf('%s = %s\n',slots{i},tmp);
else
% fprintf('%s = %f\n',slots{i},tmp);
end... |
function pass = uq_default_input_test_customdist( level )
% pass = UQ_DEFAULT_INPUT_TEST_CUSTOMDIST(LEVEL): non-regression test for the
% custom distributions functionality of the default input module
%
% Summary:
% The logistic distribution is defined in the files uq_testdist_*
% so the results of using those are chec... |
function [Dout] = DTW_distfun(XI,XJ)
% Writing this for matlab PDIST, can use distPairwise.m in ML toolbox by JANG
% A distance function specified using @:
% D = pdist(X,@distfun)
% A distance function must be of form
% d2 = distfun(XI,XJ)
% taking as arguments a 1-by-n vector XI, corresponding to a single row of X,
% ... |
function [] = laser()
clf
mirror = {-999 999 999 999
-500 -990 500 -990
-990 -765 -800 -990
990 -765 800 -990
-782 573 -782 565
-870 -478 -875 -470
782 573 870 -478};
plot_mirror(mirror);
axis square
hold on
for currentAngle = 0:1:360
if evaluateLaser(currentAngle, 0, 0, 0, mirror,... |
function y= funcg(x)
y=x(:,1).*x(:,2)+x(:,3);
end |
%store clm data points in struct for use by svm_classify gets rid of empty data and performs procrustes alignment
function [data, failed] = clmDataInit(num_extreme_frames, fileStructArray)
% only run clmFileNavigator if data hasn't been passed in
if ~exist('fileStructArray','var')
fileStructArray = clm... |
function C = corr_nd(a, b,K_f)
if nargin<1 || nargin>3 || nargout>1, error('Wrong number of arguments.'); end
C = K_f(a(:),b(:));
|
function gradientdelaycorrection( MR )
%% Perform gradient delay correction
% Two different methods are available:
% 1) uses calibration spokes and 2) uses the complete ensemble
% of spokes. Note that the 'sweep' approach requires a lot of RAM.
% Notification
fprintf('Applying gradient delay correction.................. |
%% MD clustering algorithm
%
%%
clear all; clc
tic; % Start stopwatch timer
p = path;
path(p, genpath(pwd));
% % 生成实例
% p_n = 100;
% m_n = 50;
% [T,Jm,M] = GenInstance(p_n,m_n,1);
% % 样本实例1 10*10
% T=[29 78 9 36 49 11 62 56 44 21;
% 43 90 75 11 69 28 46 46 72 30;
% 91 85 39 74 ... |
function [H,F] = make_bank_DFT(p,N)
% make_bank_DFT Generate DFT Filter Bank with N Subbands
%
% Arguments:
% p Prototype filter (impulse response)
% N Number of subbands
p = p(:); % Make column
flen = max(size(p)); % Length of prototype ... |
fs=256;
T=10;
t=(1/256):(1/256):T;
f1=5;
f2=10;
f3=15;
f4=30;
f5=50;
f6=100;
S1=sin(5*pi*t);
S2=sawtooth(1*pi*t);
S3=sinc(11*t);
S4=exp(.8*t)-.3;
%S4=;
S5=5*square(-2*t);
% S6=sawtooth(5*t);
% S7=sin(8*t);
t1=(1/256):(1/256):T/2;
t2=T/2+(1/256):(1/256):T;
S6=5*sin(-.3*t1);
S7=-2*sin(9*t2)+2;
S8=[S6 S7];
figure(1)
%wh... |
function magpart(te)
% te is the duration of the time range
% initial conditions
P = [-0.1 0 0]';
V = [0.1 0.1 0]';
% call ode45
[T, M] = ode45(@part, [0, te], [P; V]);
% plot the results
X = M(:,1);
Y = M(:,2);
Z = M(:,3);
comet3(X, Y, Z);
%XY = M(:, 1:2)
... |
function [NewElements_idx,NewNodelList] = PressureBasedDistribution_v02(x,y,z,preload,varargin)
% PressureBasedDistribution: Creation of pressure /(preaload) based reduced mesh
% INPUTS:
% x: Vector of x Coordinates of Nodes
% y: Vector of y Coordinates of Nodes
% z: Vector of z Coordinates of Nodes
% ... |
function z = zpintgrl(x,y,xi)
% SPINTGRL Cubic Spline Integral Iterpolation
% YI = SPINTGRL(X,Y,XI) uses cubic spline interpolation to fit the
% data in X and Y, integrates the spline and returns values of the
% integral evaluated at the points in XI.
%
% PPI=SPINTGRL(PP) returns the piecewise ply... |
function Vj_extremum = BTiterative_LP_for_inj_env (LP_prob,Vj_min,LP_opt)
%returns max(Vj_imag) when Vi_imag=0. Iteratively solves LP with
%constraint l<Vj_real<u
Vj_max=LP_prob.bu;
for iter=1:LP_opt.max_iter
if (LP_opt.use_mex)
[Vj_extremum, info]=greedy_LP_solution_mex( LP_prob.c, LP_prob.a, LP_pr... |
function compareWithFEM(ctrl)
[ELJager0, ELJager90, ETJager0,ETJager90,GLTJager0,GLTJager90,~,~] = importJagerFigure4();
% For simplicity, we merely import Jägers results which we know to be equal to our
% implementation.
legendText = {};
legendText{end+1} = 'J et al, 90$^\circ$';
legendText{end+1} = 'J et al... |
% Analysis to be performed on Shannon Magari's data (based on "dogs.m")
% Prediction of "hrv" - Heart Rate Variability
% from "pm25.epa" - pm 2.5 level
% -------------------------------------------------------------------
% Created: 20Jun03
% Modified: 26Jun03
% 11Nov03 - working with the extended data sets,... |
function Klqr = designLQR(A2, B2, Q, R)
[Klqr, ~, ~] = lqr(A2, B2, Q, R);
end |
classdef EngineRLL < Engine
methods (Static)
% Generate initial conditions S0
function S0 = prepare(S, pl)
% [alt, Umag, gamma, chi, lat, lon, ph, th, ps, p, q, r]
% Altitude defaults to atmosphere limit
if numel(S) > 0
alt = S(1);
else
alt = pl.atm.lim;
end
% Other defaults
% [gamma... |
function [x] = fista_gpu(y,H,Ht,lambda,alpha,Nit)
x=Ht(y);
y_k=x;
t_1=1;
T=lambda/alpha;
for k = 1:Nit
x_old=x;
x=soft_gpu((y_k+(1/alpha)*Ht(y-H(y_k))), T);
t_0=t_1-1;
t_1=0.5+sqrt(0.25+t_1^2);
y_k=x+(t_0/t_1)*(x-x_old);
end
end |
function [] = scan_comparison(path_to_bags, mathcing_indexes)
%SCANS_MATCHING_EXAMING Summary of this function goes here
% Detailed explanation goes here
if(length(path_to_bags) == 0)
disp('No bag files to read');
return;
end
if(length(mathcing_indexes) ~= 2)
disp('2 indexes are needed');
return;
en... |
function out = amdf_example(y, Fs)
% [y,Fs] = wavread(filename);
y = y(:, 1);
filesize = length(y);
blocksize = 2056;
hopsize = 1024;
hops = floor((filesize-blocksize)/hopsize) - 1;
period = zeros(hops, 1);
freq = zeros(hops, 1);
midi = zeros(hops, 1);
AMDF = zeros(blocksize-1,hops);
for i = 0 : hops - 1
st... |
close all;
clc;
clearvars settings;
global settings;
settings.mfrm = 12; %minimum no of frames
settings.T = 20; %Maximum Time
settings.raw_video = false; %raw video off
global gui ; % enable global variable
gui = gui_class(); % starting
|
% fsplot.m
% Makes a false-color plot of factor of safety along the beam and returns
% the beam's overall factor of safety, given the properties of the
% I-beam's cross-section and three shear and moment equations.
% High stresses / low factors of safety are indicated by blue/green colors,
% while red colors indicate l... |
%Computing dt-rotations in Puma3d robot for a forward movement.
function dt=puma3d_getdt(dX)
%dt=puma3d_getdt(dX)
% Compute dt2, dt3 and dt5 rotations for Puma3d robot for
% a forward longitudinal motion dX, expressed as percentile
% of the full longitudinal range of motion (0-100).
%
% Y.Mishchenko (c) 2015
%constant... |
function Report(aTrades)
% Create empty vectors to append to
myAssetsCBK = [];
myAssetsDBK = [];
% Cashflows per trade, elements >0 if sell, <0 if buy
myCashCBK = [];
myCashDBK = [];
% Sort trades into vectors by ISIN
for i = 1:length(aTrades.side),
% Note: the so... |
function check_VSanatomy(p0,p1)
% compare 2 anatomy directories
% checks vAnatomy.dat, left & right .Class files, left & right .Gray files
%
% e.g. check_VSanatomy('jones','skeri9999')
if ispc
anatDir = 'X:\anatomy';
else
anatDir = '/raid/MRI/anatomy';
end
file = 'vAnatomy.dat';
[a0,v0] = readVolAnat(... |
function rotadas = girar(data,angulos)
rotadas = [];
for i=1:size(data,1)
if angulos(i) < 0
sentido = -1;
else
sentido = 1;
end
giro = sentido*floor(abs(angulos(i))/pi*50 + 0.5);
if giro < 0
giro = giro + 100;
end
giro ... |
% ----------------------------------------------------------------------- %
% main_YYYYMMDD.m
%
% Author: Hideyuki Kimpara, Worcester Polytechnic Institute
%
% This code uses the Matlab interface to the OpenSim API to run a trial
% to connect simulink simulator and OpenSim analysis.
% This example borrows from ... |
function ang = cosPatchNormal(nrm)
x = nrm(:,:,1);
y = nrm(:,:,2);
z = nrm(:,:,3);
[N_scan N_point] = size(x);
row_zero = zeros(1, N_point);
col_zero = zeros(N_scan, 1);
vertical(:,:,1) = [x(2:end,:); row_zero];
vertical(:,:,2) = [y(2:end,:); row_zero];
vertical(:,:,3) = [z(2:end,:); row_zero];
horizontal(:,:... |
function [ ENFSignals ] = getENFSignals( recordings, ENFExtractorPower, ENFExtractorAudio, powerAudioClassifier)
ENFSignals(length(recordings)).enf = 0;
ENFSignals(length(recordings)).gridID = 0;
ENFSignals(length(recordings)).recordingType = 0;
ENFSignals(length(recordings)).name = 0;
%Gets ENF sig... |
clear all;
close all;
fig = figure;
matrix_sizes = [128, 256, 512, 1024, 2048, 4096];
parallel_timings_no_simd = [
0.020185600 0.011102210 0.010713550 0.009270720 0.012251430 0.026384570 0.023694910 0.422775530;
0.129443240 0.058825340 0.055001560 0.048942400 0.048647270 0.040422010 0.085471470 ... |
function [IMU_U] = imuSEAtoU(IMU_SEA)
%IMUSEATOU Changes SEAsnake accelerometer or gyro readings of all of the
% individual modules into the first modules frame according to USnake
% convention
IMU_U = zeros(size(IMU_SEA));
IMU_SEA = fliplr(IMU_SEA);
% In the SEA snake the module frame rotate with respect to the fol... |
function tpredict(results,maxfuture)
numbm = size(results,1);
for i = 1:numbm
bmname = results{i,1};
bmerror = results{i,3};
pcnterr = results{i,5};
power = results{i,9};
pactual = results{i,12};
thalf = 5*(1:size(power));
t = 5*(1:size(pactual));
... |
function nav(x_start,y_start,x_end,y_end,RAD_heading, moteID)
% nav(x_start,y_start,x_end,y_end,RAD_heading, moteID)
% Allows for command line navigation of COTSBOTS.
%
% INPUTS: (x_start, y_start) initial coordinates
% (x_end, y_end) destination coordinates
% RAD_heading headi... |
function object_task_correlations(pipe)
% There are two forms of this task:
% 1) hab session containing 4 trials, and test session containing 1 trial
% 2) 5 separate session each containing 1 trial.
if pipe.Experiment.getNumSessions() == 2
object_task_correlations_for_4hab_1test(pipe);
elseif pipe.Expe... |
function [Qpwr_df, Tissue_types,SigmabyRhox,Mass_cell,Mass_corr,Qpwr2] = gen_Q(dirname,SAR_type,anatomy)
%% Read input df files and generate Q matrices based on them
disp('Reading deadface files...');
t0_df = cputime;
% Air_seg = df_read(fullfile(dirname,'airSeg.df')); %Tissue density
Tissue_types= df_read(fullf... |
function [anns] = generate_anns()
trainingFcn = {'trainlm', 'traingd'};
activationFcn = {'tansig', 'purelin'};
neurons = [10, 100];
hiddenLayers = [1,2];
trainFcn_size = size(trainingFcn, 2);
activationFcn_size = size(activationFcn, 2);
neurons_size = size(neurons, 2);
hiddenLayers... |
function [X,Y,Z] = parMyModsel(folder1,feature,numRaws,c_begin,c_end,c_step,g_begin,g_end,g_step)
% Model selection for (lib)SVM by searching for the best param on a 2D grid
% example:
%
% load heart_scale.mat
% [X,Y,Z,hC] = modsel(heart_scale_label,heart_scale_inst);
%
% where X,Y,Z are the contour data and hC is the ... |
%% rtanx_task_instructions_test2
% This tests if the participant understands the probabilities are reciprocal
%% Test
test2txt1 = ['If you can sense the probability of reward for one image, \n\n '...
'you can understand the probability of reward for the other. \n\n '...
' \n\... |
function [indCellTracks,falseCapture,cellVelocities,effectiveDiamaters] = Cell_Counter_Final()
%Takes Text Files from UMUTracker, and Organizes Data
%Puneeth Guruprasad - 2/2/2018
% --------------------------------------------------------------------------
[FileName,PathName,FilterIndex] = uigetfile('.txt','Choose te... |
function [ chfi ] = filter_data_bpass( chi, fsi, n_fi, Wni )
fnq= 1/(2*(1/fsi)); %nyquist frequency
Wn = [Wni(1)/fnq Wni(2)/fnq];
[b,a] = butter(n_fi,Wn);
chfi=cell(size(chi));
for i=1:size(chi,2)
chfi{1,i}=filtfilt(b,a,chi{1,i});
end
end
|
clear;
close all;
d_y_rel = 0.2;
max_cert = 10;
x0 = 0;
y0 = 2;
x1 = 30;
k1 = 0.25;
k2 = 0.4;
d_k1 = 0.0025;
d_k2 = 0.004;
d_b1 = 0.1;
d_b2 = 0.1;
Nx = 250;
Ny = 250;
clr1 = [1, 0, 0];
clr2 = [0, 0, 0];
tit1 = '$th_1$';
tit2 = '$th_2$';
x_draw = linspace(x0, x1, Nx);
b1 = y0 - k1 * x0;
b2 = y0 - k2 * x0;
linfit1 = [k... |
% WPTREE/LOADOBJ load によるコール
% M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 29-Sep-2001.
% Copyright 1995-2003 The MathWorks, Inc.
% $Revision: 1.1.4.1 $ $Date: 2004/07/28 05:02:20 $
|
function [screenIndex, Data] = YouMissedTheCannonball_TryToCollectIt(taskParam, screenIndex, Data, whichPractice)
%YOUMISSEDTHECANNONBALL_TRYTOCOLLECTIT This function tells participant that cannonball was caught, although instruction was
% to miss it
%
% Input
% screenIndex: indicates current screen of inst... |
% Es 10
% 10.a
% Given a signal x(n) = [3, 2, 1, 0, 1], n in [-2, 2]
% Given a LTI system with h(n) = [1, 3, 2.5, 4, 2], n in [0, 4]
% Compute the output of the system using conv. Which is the support of y(n)?
% Exploiting the convolution theorem, compute Y(z) = X(z) H(z)
% Which is the order of polynomial H(z)?
% 10.... |
% Transform 3D point (8,5,80) from camera coordinate frame to image coordinate frame
% (u,v) by writing a function.
%%the Coordinates given are at the end after Calibration is hit (Use the ones with uncertainties)
%Focal Lenght
fx = 693.15125;
fy = 690.66305;
%Pricical Point
px = 285.67948;
py = 244.42955;
%Homogen... |
function [Average_Precision,OneError,RankingLoss,Coverage]=RankingBasedMeasure(Outputs,test_target)
% syntax
% [Average_Precision,OneError,RankingLoss,Coverage]=RankingBasedMeasure(Outputs,test_targets)
%
% input
% test_targets - L x num_test data matrix of groundtruth labels
% Outputs ... |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copyright 2018 Crypto4a Technologies Inc.
%
% Permission is hereby granted, free of charge, to any person obtaining a
% copy of this software and associated documentation files (the "Software"),
% to deal in the Software without restriction,... |
function set_markersize(hh, ms)
set(hh, 'MarkerSize', ms); |
function Pelpla(x,n)
m = dicomread(x);
l=dicominfo(x);
nframe=l.NumberOfFrames();
imshow(m(:,:,n), []);
hold off
end |
function I_rec = Decompress(I_comp)
[N, N3] = size(I_comp.data);
C = N3/N;
data = reshape(full(I_comp.data), N, N, C);
H = haarTrans(N);
for c=1:C
I_rec(:,:,c) = H*data(:,:,c)*H';
end
I_rec = I_rec(1:I_comp.h, 1:I_comp.w, :);
|
%%% Matlab script for plotting, measuring and transforming distributions
%%%
%
% specify mean and covariance of the 2D Normal distribution
%
% mean
mu = [ 5 ; 2];
% covariance matrix
sigma_x = 2; sigma_xy = 0;
sigma_yx = sigma_xy; sigma_y = 1;
C = [ sigma_x^2 sigma_xy;
sigma_yx sigma_y^2;
];
% number o... |
function out = PM(param)
% if param.B
%
% inFT = fftNc(param.O);
% Bufferdata = inFT(param.Bmstop==1);
% temp1 = param.data.*inFT./sqrt(abs(inFT).^2+param.B.^2);
% param.B = param.data.*param.dataMask.*param.B./sqrt(abs(inFT).^2+param.B.^2);
% inFT = temp1;
%... |
classdef CZICompression < uint16
%CZIPIXELTYPES Enumeration class describing compression algos used by CZI File
%Format
%
% AUTHOR: Stefano Masneri
% Date: 13.10.2016
enumeration
Uncompressed (0) % Data contains uncompressed pixels. Data is a stream
% of items with the specifie... |
function output = checkedSystem(cmd)
% Call system(cmd) and verify successful completion reporting
% errors if any
[status,msg] = system(cmd);
msg = sprintf(['Evaluating ' ...
'command\n\n %s\n\nproduced output:\n\n%s\n'], ...
cmd, strip(msg));
assert(status == 0, 'CoderSwig:System:Failu... |
function altered_mask = CS6640_alterMask(M,SE,string_)
% CS6640_alterMask - performs operations on movie object frames
% On input:
% M (Matlab movie struct): segmentation movie (binary)
% SE (Stucturing element): created using matlab function "strel"
% (type 'help strel' in command window to learn this)
% ... |
function freqpulsesana_SU
animalid = '180626';
block = 11;
basepath = ['C:\Users\Julia\work\data\' animalid '\'];
% supath = [basepath 'multiunits\'];
supath = [basepath 'singleunits\'];
basename = [animalid '_block' int2str(block) '_tet'];
files = dir([supath, basename, '*.mat']);
prestim = 300;
% poststim = 300;
... |
function clean()
% Function to clean all third party dependencies
affineDetectors.cleanDeps();
cleanVlFeat();
function cleanVlFeat()
fprintf('\n----- Deleting vlfeat -----\n');
cwd=commonFns.extractDirPath(mfilename('fullpath'));
installVersion = '0.9.14';
installDir = fullfile(cwd,'thirdParty');
vlFeatDi... |
function plot_ex1(K, n);
format long;
hold on;
%numer1 = load(['ex1_Nx',num2str(n),'_K',num2str(K),'.dat']);
%x1 = numer1(:,1); y1 = numer1(:,3); y2 = numer1(:,4);
%plot(x1, y1, 'o', x1, y2, '-k');
%legend(['k=',num2str(K)], 'exact');
for K = 2:4;
numer1 = load(['ex1_Nx',num2str(n),'_K',num2str(K),'.dat']);
x1 =... |
function [x,fval,exitflag,output] = assgn_code_sa(x0,lb,ub)
% This is an auto generated MATLAB file from Optimization Tool.
% Start with the default options
options = saoptimset;
% Modify options setting
options = saoptimset(options,'Display', 'iter');
options = saoptimset(options,'HybridInterval', 'end');
options = s... |
function v=readmod14(prefix,file,silent)
% v=procmod14(file)
% read modis data and return v.lon v.lat v.data
pfile=[prefix,file];
v=load(pfile);
v.file=file;
[v.time,v.timestr]=rsac2time(file);
if ~exist('silent','var'),
fprintf('file name w/prefix %s\n',pfile);
fprintf('file name %s\n',file);
... |
function []=change_pitch(filename)
keySet={'B3','C4','Db4','D4','Eb4','E4','F4','Gb4','G4','Ab4','A4','Bb4','B4','C5'};
valueSet=[246.94,261.63,277.18,293.66,311.13,329.63,349.23,369.99,392.00,415.30,440.00,466.16,493.88,523.25];
map=containers.Map(keySet,valueSet);
addpath('~/Desktop/Matlab/sap','~/Desktop/Matlab/... |
% When executing the following code, you may need to
% modify it to match your acquisition hardware.
imaqhwinfo
vid = videoinput('macvideo',1);
%% determine frame rate
set(vid,'FramesPerTrigger',100);
start(vid);
wait(vid,Inf);
% Retrieve the frames and timestamps for each frame.
numframes = get(vid,'FramesAvailabl... |
function h = shStrsIni(strs, varargin)
% Show a string list (Initialization).
%
% Input
% strs - string list, 1 x n (cell)
% varargin
% show option
% ti - title, {[]}
% cl - string color, {[.4 .4 .4]}
% ftNme - font name, {'Arial'}
% ftSiz - font size, {23}
%
% Output
% h ... |
clc
close
clear
%读取的txt文件名
filename = 'test_cubic.txt';
%filename = 'tree.txt';
%创建网格:节点、边、面
mesh = HE_Mesh;
%读取txt文件
mesh.LoadFromTxt(filename);
%计算theta角:
%cal_theta(mesh)中search函数并非必须,后期调试时若速度慢则考虑删去
theta=cal_theta(mesh);%弧度
theta = theta/pi*180;%角度
%画图
[T,Xb]=search(mesh);
TR = triangulation(T,Xb);
P = in... |
function oi = oiDefocus(defocus)
% OIDEFOCUS - Create an human wvf oi with some amount of defocus
%
% Input:
% Zernike defocus coefficient (in microns)
%
% Output:
% oi - Human wvf structure with the defocus set
%
% See also: wvfDefocusDioptersToMicrons and wvfDefocusDioptersToMicrons,
% oiCreate
%
% BW... |
function data_save_travelling_wave(x, y, H1, H2, m2, m3, s1, s2, Q)
filename = data_filename_travelling_wave(x, H1, H2, m2, m3, s1, s2, Q);
save(filename, "x", "y", "H1", "H2", "m2", "m3", "s1", "s2", "Q");
end
|
function [sp3 dat]=prosp3(prename1,prename2)
%
fprintf(1,'Generating Orbits:\n')
fprintf(1,' Reading Orbit files...\n')
% Read Precise Ephemeris files
[sp31 dat]=readsp3(prename1);
if ~strcmp(prename2,'none')
[sp32 dat2]=readsp3(prename2);
end
fprintf(1,' Processing...\n')
% Add Next day f... |
classdef ModelInput < AMF.ModelComponent
properties
type
func
predictor
parameters
method
initVal
initTime
args
pidx
end
methods
function this = ModelInput(index, name, type, args, method, meta)
thi... |
% trains an SVM using all three features (Zero-crossing rate, Spectral
% Centroid, and Spectral Flux). Saves SVM and training results to 'svm.mat'
% --Inputs--
% speech_dir: directory containing speech training files
% music_dir: directory containing music training files
% (they both default to the provided training d... |
%-------------------------------------------------------------------------
% defineComPort.m
%-------------------------------------------------------------------------
% Description: creates a serial port structure (object) used to
% connect matlab with MCU
%% 1. Specifies the ... |
function centroids = initCentroidsForgy(X, k)
# centroids = initCentroidsForgy(X, k) initializes the centroids using the Forgy algorithm
# for the initialization of the centroids
# The Forgy algorithm randomly selects k samples from the given data as centroids.
m = size(X,1);
if (k > m)
error('Amount of data less t... |
file='附件一:325个样本数据.xlsx';
file2='附件三:285号和313号样本原始数据.xlsx';
file3='附件四:354个操作变量信息.xlsx';
%读取附件一325个样本
[data_354]=xlsread(file,'Q4:NF328'); %附件一354个操作变量
[raw_7]=xlsread(file,'C4:I328'); %附件一原材料7个属性
[Daishen_2]=xlsread(file,'M4:N328'); %附件一待生催化剂2个属性
[Zaishen_2]=xlsread(file,'O4:P328'); %附件一再生催化剂2个属性
[pro... |
function [rM, rSD, rN, rMn] = getML_mRateSac(fname, bins, crtf, nvf, dirf, recompute)
% get mean rate for each good session
% INPUTS:
% fname - 'txt' filename
% dtype - 'MT' or 'LIP'
% bins - time bins for which spikes rate will be calculated
% crtf - [0 1]=both correct and incorrect, 1=correct only, 0=incorr... |
function [rz,ptr]=de_zone_sub2a(biny,lastBit,ptr)
thd=zeros(1,2);
[thdd,ptr]=decode_stationary_source_lenr(biny,3,1,ptr); thd(1)=thdd;
[thdd,ptr]=decode_stationary_source_lenr(biny,4,1,ptr); thd(2)=thdd*4;
rsep=cell(1,2);
%decode rsep{2}:
cbook=17; [rsep{2},ptr]=de_runs_0seps(cbook,biny,ptr);
%decode rsep{1}:
lB1=... |
function [Q, R, E] = QR(A, varargin)
% QR Orthogonal-triangular decomposition.
% [Q,R] = QR(A), where A is m-by-n, produces an m-by-n upper triangular
% matrix R and an m-by-m unitary matrix Q so that A = Q*R.
%
% [Q,R] = QR(A,0) produces the "economy size" decomposition.
% If m>n, only the first n columns ... |
function idx = findClosestCentroids(X, centroids)
%FINDCLOSESTCENTROIDS computes the centroid memberships for every example
% idx = FINDCLOSESTCENTROIDS (X, centroids) returns the closest centroids
% in idx for a dataset X where each row is a single example. idx = m x 1
% vector of centroid assignments (i.e. each... |
function [neighbors] = neighbor_ring(nside, ipix)
% neighbor_ring(nside, ipix)
% Find the pixel neighbors in a ring scheme
%
% Inputs:
% nside: Pixel resolution, power of 2 less than 30
% ipix: Pixel values in nest
%
% Output:
% neighbors in ring scheme
npix = nside2npix(nside);
if ipix > npix
error('Not a valid ... |
%% Script to find optimal k-NN and codebook size
%
% Ke Ma & Chris Bodden
%
%% construct training and testing sets
image_dir = 'datasets/scene-category';
data_dir = '../features/scene-category-llc';
categories = {'bedroom', 'CALsuburb', 'industrial', 'kitchen',...
'livingroom', 'MITcoast', 'MITforest', 'MIThighwa... |
pathBase = '../Base/';
[imaTab, imaTabTest] = chargeXTrainTest(pathBase);
X_moy=image_moy(imaTab);
imaTabCentre = visage_centre(imaTab, X_moy);
[u, Lambda] = eigenfaces(imaTabCentre);
% u = reshape(u,size(imaTab,1),size(imaTab,2),size(imaTab,3));
X = zeros(4096,1);
X = reshape(imaTab(:,:,50), [size(X,1) * size(X, 2),... |
function error = HeatDiffusionPlot( timeStep, spacialResolution, ...
diffusionConstant, domain, simLength)
%%%%%%%%%% Creat transformation matrix A for the system and inverse it %%%%%%%%%
left = -diffusionConstant * timeStep / spacialResolution^2;
center = 1 + 2*(d... |
function [ trials_data ] = SynchronizeData( subfolder )
%SYNCHRONIZEDATA Synchronizes data from two smart watches
%
% -------------------------------------------------------------------------
% Author: Tiago P M da Silva (dept. DIBRIS, University of Genova, ITALY)
% Divya Haresh Shah (dept. DIBRIS, University ... |
% Main file to run different color normalization techniques
clear
clc
%% Define source and target images (Add target and source images to the folder "images")
%source=imread('images/source1.png');
%target=imread('images/target1.png');
nstains=2;
lambda=0.02; % Use smaller values of the lambda (0.01-0.1) for better r... |
%%Genetic Alogrith for a glider
clear
clc
close all
%%Generate Initial Parameters
parameters
%%Create Initial Random Population
xbin = randi(10,[popsize,N])
disp('Initial Population')
disp(xbin)
disp(' ')
iteration = -1;
while iteration < maxiteration
Fi = zeros(popsize,1);
for ii = 1:popsize %%Calculate ... |
function init_string(option)
global vinf;
drivetrain=vinf.drivetrain.name;
% tests are: 1) PCT-HEV 2) FCT-HEV 3) PCT-CV 4) FCT-EV
test=evalin('base','tst'); %current test being run
cycle=evalin('base','cyc'); %current cycle being run
switch option
case 'begin'
if cycle==4 %add add'l AC load only for SC03 cycle
... |
%% GENERATE A SINGLE BRAIN VASCULATURE NETWORK (DVN)
% This function will take morphometric data from http://cng.gmu.edu/brava
% to produce vectors containing the coordinates, lengths and node numbers
% for each patient.
function [xns,yns,zns,bns,cns] = Generate_Network(Subject)
cns = Subject(:,2);
xns = S... |
function plotnn(data,chname,scanrate,time)
% plotnn(data,chname,time)
% plots the given channel and its nearest neighbors
% time (optional) specifies the time range [,)
% over which to plot the channel, and defaults to the
% entire sequence
dmax = max(max(data));
dmin = min(min(data));
if (nargin == 4)
t = time(1):1/s... |
function ABCD = ABCD_fun(model);
% ABCD representation of Dynare model
% prepare inputs
decision = model.decision;
n_s = model.n_s;
n_xi = model.n_xi;
obs_y = model.obs_y;
obs_x = model.obs_x;
if ~strcmp(model.shock,'fg')
% ABCD representation in macro aggregates y
A_y = decision(1:... |
function wsMocs = cmuMocQ(src, joinF, XQs)
% Restore quaternion to CMU motion capture data.
%
% Input
% src - cmu src
% joinF - joint
% XQs - quaternion set, 1 x m (cell), dim x nF
%
% Output
% wsMoc - mocap data
%
% History
% create - Feng Zhou (zhfe99@gmail.com), 04-05-2011
% modify - ... |
function results = ...
find_posterior( show, config, output_width, results )
% how many tracks to find
M = length(show.indexes)+1;
T = show.T;
W = show.W;
SC = show.CostMatrix;
eta = config.eta;
% to calculate TL and H we need a slightly different cost matrix
HT_SC = SC;
% preprocess SC with the exp
% doing ... |
function imgobj = Get_mat2D(imgobj, sobj)
%%%%%%%%%%
datap = size(imgobj.dFF_s_ave, 1);
% transform 3D-mat into 2D-mat
mat = zeros(5 + datap, size(imgobj.dFF_s_ave,2), size(imgobj.dFF_s_ave,3));
mat(1:datap,:,:) = imgobj.dFF_s_ave;
imgobj.mat2D = reshape(mat, [], imgobj.maxROIs);
if isfield(imgobj, 'dFF_s_ave_ori')... |
clear all
close all
clc
pkg load control
t = 0.0001:0.01:20;
y= zeros(2000,1);
i = 1;
for s = 0.0001:0.01:20;
num = 0.5*s^4 + 0.5*0.002*s^3+(1+0.5*0.02*0.02)*s^2 + 0.002*s+0.02*0.02;
den = ((0.5*s^2+2*s+1)*(s+0.7)+0.5*s^2+1)*(s^3+(0.02*0.02)*s);
y(i) = num/den;
i=i+1;
endfor
figure(1)
plot(y) |
function [Q,R,G,Gi,stats] = ilsReduce(Q,R,options)
[m,n] = size(R);
Gi = eye(n);
G = eye(n);
%Q = eye(n);
if nargin < 3
options.algorithm = 'LLL';
options.delta = 1;
end
stats.iterations = 0;
if strcmp(options.algorithm,'LLL')==1
i = 2;
while i <= n
if abs(R(i-1,i)) > abs(R(i-1,i-... |
global saveProcess
%% Epoching
varExist = exist('spect2Plot','var');
if varExist == 0
spec2Plot = true;
end
alignEvent_MI = spectrogramData{1}.state.ST_MOV;
alignEvent_MIT = spectrogramData{1}.state.ST_STOP;
alignEvent_Base = spectrogramData{1}.state.ST_HOLD;
params.params_epoching.timeBeforeEventMI = 2;
params.... |
%{
Jacob Leonard
ITP 168 - Fall 2015
jaleonar@usc.edu
Revision History
Date Changes Programmer
-------------------------------------------------
9/16/2015 Original Jacob Leonard
%}
fprintf('Do the follow calculations as quickly as possible. Good Luck!\n');
num1 = randi(10);
num... |
function [Gxx_avg,f_Gxx] = MyAvgFFT(xn,fs,Nrecs,win)
% [Gxx_avg,f_Gxx] = MyAvgGxx(xn,fs,Nrecs)
% Inputs:
% xn = Input Vector Time Array
% fs = Sampling Rate
% Nrecs = Number of records desired
% Outputs:
% Gxx_Avg = Average Gxx from the operation
% f_Gxx = Frequency of the Gxx avera... |
function out=csvimport(filename)
% (C) Nov 25, 2014, Pratik Chhatbar, Feng Lab
% MUSC Stroke Center, Charleston, SC
% chhatbar@musc.edu, pratikchhatbar@gmail.com
% line delimiter is \r\n, or 13 10 in sequence
% element delimiter is ', '
fh=fopen(filename);
filenum=fread(fh);
fclose(fh);
rin=find(filenum==13);
nin=fi... |
function prm = rem_short(proll, len)
% function prm = rem_short(proll, len)
%
% INPUTS
% proll piano-roll matrix
% len max lenght of notes to be removed
%
% OUTPUTS
% prm post-processed piano-roll matrix
%
% Post-processing of piano-roll matrix. Removes all notes that are shorter
% then thr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.