text stringlengths 8 6.12M |
|---|
function SNAPfNW = ArrangeByComponentSVD(FINT,nmodesU,SSd)
% Re-arrange basis matrix, and multiply it by singular values
%if isempty(SSd)
SSd = ones(nmodesU,1) ;
%end
nsnap = size(FINT,2) ;
M = size(FINT,1)/nmodesU ;
SNAPfint = zeros(M,nmodesU*nsnap) ;
iacum = 1;
for i=1:nsnap
for j=1:nmodesU
SNAPfNW... |
%comparisons = {'genotype',{'WT','Df1'};'animal',{'RZ2','RZ3','RW2','RW3'};{'animal','genotype'},...
% {'RZ2','WT'};{'animal','genotype'},{'RZ3','WT'}};
comparisons = {{'genotype','animal','animal','animal','animal','genotype'},{'WT','RW2','RW3','RZ3','RZ2','Df1'}};
allEpochs = {'sleep','saline','ketamine... |
function [ predict_label_final ] = norm_predict_label( predict_label,num_each_track )
%NORM_PREDICT_LABEL Summary of this function goes here
% Detailed explanation goes here
predict_label_final = [];
for i = 1:1:size(num_each_track,1)
added = sum(num_each_track(1:i));
num = num_each_track(i);
stage = pr... |
function Hess = findHessian(x, n, MATRICES)
Hess = zeros(n*3,n*3);
s = findS(x,n,MATRICES);
invs = inv(s);
for i = 1:(n*3)
for j = 1:(n*3)
Hess(i,j) = trace(invs*MATRICES(:,:,i)*invs*MATRICES(:,:,j));
end
end
end |
function[xp,xm]=solve_quad(a,b,c)
if (b >= 0)
xp = (2*c)/(-b-sqrt(b^2-4*a*c));
xm = (-b-sqrt(b^2-4*a*c))/(2*a);
else
xp = (-b+sqrt(b^2-4*a*c))/(2*a);
xm = (2*c)/(-b+sqrt(b^2-4*a*c));
end
a=1;b=-10^6;c=1;
z = -4*a*c/b^2;
delta = abs(b)*(1+z/2-z^2/4);
x_m = (-b-delta)/(2*a);
x_m =
9.99... |
function [E, Niv, Nivpond] = gene_energyLevelBC(sig, fs, show)
%%%%
% FUNCTION:
% Calculation of energy and level into the 24 critical bands from a signal
%
% USE:
% [E, Niv, Nivpond] = gene_energyLevelBC(sig, fs, show)
%
%
% INPUT:
% sig : acoustic signal, monophonic (Pa)
% fs : sampling frequenc... |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This function calculates the exact solution of u.
% The reader may choose different model second order ellitpitc problems but
% one has to match rhs.m, exactu.m, and gradientu.m function to the same
% second order elliptic problems.
%%%%%%%%%%%... |
function [ICs]=cchengHigh_Order(HIM,M,k,Initial)
%% Code Comments:
% HIM is the image cube.
% M is the number of components to generated using high order
% k is the order of statistics. For example, k=3, is the skewness, k=4, is
% the kurtosis, k=5 is the 5th moment, and so on...
% Initial condition preference, 0 is th... |
function robot = doubleElbow
% doubleElbow planar robot with geared 2R elbow joint (Simulink Example 6)
% doubleElbow creates a two-link planar robot that resembles planar(2),
% except that the elbow joint has been replaced by a pair of revolute
% joints close together, which are geared 1:1. This kind of join... |
function [x, y] = extData(self, plotNum)
if (plotNum < 1 || plotNum > self.N)
error('Plot number exceeds the range');
else
x = self.xdata{plotNum}';
y = self.ydata{plotNum}';
end
end |
function filter_pred=TrPMBM_all_prediction(filter_upd,F,Q,p_s,weights_b,means_b,covs_b,Lscan,k,T_alive,F1,F2,p_s1,p_s2,d_spawning)
%Author: Angel F. Garcia-Fernandez
%This function works for two spawning modes, see Scenario_spawning. It is
%straightforward to add more spawning modes.
%Prediction for Poisson componen... |
function [dtm,x]=testdtmx(wellname)
if strcmp(wellname,'SS160')
%SS160
[~,~,~,~,~,shaledt1]=selectsandshale('../wells/177114095100_Orig+Edit+RckPhys.las',4,5,95,17,6000,7000);
[~,~,~,~,~,shalephi1]=selectsandshale('../wells/177114095100_Orig+Edit+RckPhys.las',4,5,95,9,6000,7000);
[~,~,~,~,~,shaledt2]=se... |
%% Header
%
% Title: createFigure.m
%
% Precondition: nothing
%
% Postcondition:
% Erzeugt ein Grafikfenster in dem das Spiel Abläuft
%
% Call:
%
% Variables:
%
% Modified:
%
%
function [fighandler] = createFigure()
%% CONSTANTS
%#~~~~~~~~~~~... |
clear all
close all
% Set Data Parameters
tstart = 0.1;
tend = 0.7;
save_on = 0; %save parameter
course = 1; %High Freq or Low Freq
% Load Ring Size Sets
load('/media/datadrive/LIINC Data/Sameer/FlightSim_APL/BFOpenLoop_BFOL707_epochData.mat')
% Contents: eegdata_highfreq_all,eegdata_lowfreq_all,workload_highfreq_all,... |
function sss2cntrSM(msiggloc,fh,n,m,ncontr,contrsp)
% SSS2CNTRSM, Function for SSS2, this overlays contours, on the current image.
% Intended to be used by SSS2, for plotting gradient information
% Steve Marron's matlab function
% Notes: This assumes "matrix style coordinates", where
% ... |
classdef Interactions < handle
properties
places; % places inside group to update potential (an array)
condPlaces % places in the full data array the potential depends on (an array same size as places)
potential % handle to potential that is the came for all places (single instance) ... |
classdef TExpData < handle
%
properties
animal
series
iseries
exptList
data
CellInfo
end
methods
function obj = TExpData()
obj.animal = [];
obj.series = [];
obj.iseries = [];
obj.exptList = [];
... |
function [x,iseed] = usar(iseed, nd);
nd=nd+500;
xx=zeros(nd,1);
%randn('state',iseed);
randn('state',sum(100*clock));
e=randn(nd,1);
u=e*0.0096;
i = 3;
xx(1) = 7.3;
xx(2) = 7.3;
while i <= nd;
xx(i) = 0.0055 + 1.3438*xx(i-1) - .3438*xx(i-2) + u(i);
i = 1+i;
end;
x=xx(501:nd);
nd=nd-50... |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Some simulations:
% Excitatory Neurons
% SingleNeuron(100,0.01,0.02,0.2,-65,8,14) regular spiking
% SingleNeuron(100,0.01,0.02,0.2,-55,4,14) intrinscally bursting
% SingleNeuron(100,0.01,0.02,0.2,-50,2,14) chattering
% Inhibitory Neurons
% SingleNeuron(100,0.01,0.1,0.2,-65... |
function [ Spin1 ] = kicker_onlyspin( Coord,Spin,turn,nukick,Ampl,nusp )
% [ Coord1,Spin1 ] = kicker( Coord,Spin,turn,Ampl,nusp )
% This function computes the effect of the phase space coordinates and on
% the spin vector due to a vertical kicker.
% Input:
% Coord is the 6D phase space vector
% Spin is the... |
%Sistema de edos
function dydt = myeq(t,y,DATA)
h = y(1); % y(1)= distancia coet a l'origen m
v = y(2); % y(2)= velocitat coet m/s
th = y(3); % y(3)= angle del coet respecte de la horitzontal (angle de vol)
x = y(4); %y(4)= recorregut horitzontal en m
vG = y(5); % y(5)= perdues de velocitat degut a la gravetat... |
trainX = dlmread('../train/words_train.txt');
trainY = dlmread('../train/genders_train.txt');
p = randperm(4998,2500);
ind = 1:4998;
p2 = setdiff(ind,p);
trainData = trainX(p,:);
testData = trainX(p2,:);
trainLabels = trainY(p,:);
testLabels = trainY(p2,:);
addpath('libsvm')
% X = sparse(trainData);
% X_2 = spars... |
newdata= input('enter data here =');
size=length(newdata);
%initialized the vector with zeros where the new data will be stored
NormalizedVar=zeros(size,1);
MEAN = mean(newdata);
stddev= std(newdata);
for k=1:size;
NormalizedVar(k)= (newdata(k)-MEAN)/stddev;
end
|
% script file for testing different algorithms under various parameter
% settings
% authors: Miao Liu, Girish Chowdhardy
%
clear, clc,
curDir = pwd;
mainDir = fileparts(fileparts(curDir)); % go up 2 directories
addpath(fullfile(mainDir,'API'));
addpath(fullfile(mainDir,'domains/Pendulum'));
rand('... |
function [t] = doLineSearch( objfun, xc, sdir )
%DOLINESEARCH perform backtracking linesearch
%
% input:
% objfun function handle for objective function
% xc current iterate
% sdir search direction
%
% output:
% t line search parameter
% evaluate objective function
[fc, dfc] = objfun( xc );
... |
% Raw_CT_FIJI_format_v2.m
% Christopher Zahasky
% 1/15/2016, updated 4/19/2018
% This code loads stack of images in clincal CT scan, centers the image,
% coarsens the image and crops the edges outside the core assuming a
% cyclindrical core. Read options carefully to determine proper input. Note
% that paths to t... |
function [net, info] = train_regression_DANplus(varargin)
opt.model = 'vgg-face';
run('/opt/zhangcl/matconvnet/matlab/vl_setupnn.m');
net = load(['/opt/zhangcl/' opt.model '.mat']);
net = dagnn.DagNN.fromSimpleNN(net);
%net = net.net;
inputVar = 'data' ;
%[opts, varargin] = vl_argparse(opts, varargin) ;
opts.imdbPath ... |
function [P] = get_spectrogram_orig(Y, padding, fs)
% if ~exist('fs', 'var')
% warning('sample rate was not specified: using the rate for TIMIT instead.. If the audio file is not from TIMIT corpus, you should set this value correctly!!');
% fs = get_constant('TimitSampleRate');
% end
% wintime = get_constant('Ti... |
function [TX_sync,SYNC] = syncSignals_NxN(RX,TX,SYNC)
% Last Update: 04/11/2019
%% Input Parser
% Check for Sync Method and Debug Flag:
SYNC_method = 'complexField';
debug = false;
avoidSingularity = true;
if nargin == 3
if isfield(SYNC,'method')
SYNC_method = SYNC.method;
end
if isfield(SYNC,'de... |
function [f,bpm] = Frequency2Note(baseband,ratio,beats)
% input:
% baseband: type: struct;
% ratio: type: double;
% beats: type: 1*n matrix.
%
% output:
% f: type: struct, song;
% bpm: type: numerical
freq = [];
for i = -7 : 12
freq = [freq,Note2Frequency('C',i)];
end
map = containers.Map(freq,-7:12);
min_beats ... |
function x=coarse_correction(x,F,K,K_coarse,X_coarse,hzc,icl3,X,params)
n = size(X{1});
res = reshape(F-K*x,n);
F_c = restriction(res,hzc,icl3,X,params);
% F_c_f = restriction_fortran(res,hzc,icl3,X,params);
% err_fort=big(F_c-F_c_f)
F_coarse = F_c(:);
if params.apply_coarse_boundary_conditi... |
function GMM_output = evaluate_GMM_output(GMM_output)
%for pid = 1:length(GMM_output)
for pid = 1:length(GMM_output)
outputs = GMM_output(pid).output;
annotations = GMM_output(pid).annotation;
brains = GMM_output(pid).brains;
dice_list = [];
for index = 1:size(outputs,4)
... |
function [AET,DEF,RUNOFF,SNOWS,SOILS,RUNOFFSNOW]=simplehydromodel(TMEAN,PPT,PET,AWC,soil,snow);
% PPT and PET should be in mm
% data can be daily/monthly
% simple 1-bucket soil-runoff model
DR=NaN;
AET=single(NaN*ones(size(PPT)));DEF=AET;RUNOFF=AET;IN=AET;RUNOFFSNOW=AET;
% start with empty soil bucket
snowstorage=snow... |
function [ value,primal_epsilon ] = cost_function( obj,Z)
%
% This function calcualtes the primal infeasibility and the primal
% objective
%
% SYNTAX : [ value,primal_epsilon ] = cost_funciton( obj,Z)
%
% INPUT : obj : system dynamics
% Z : optimal state and control
%
% OUTPUT... |
function gbest = mgGPmain(func_mass,Npop,Ngen,Nobj,Nvar,varargin)
%main function for multi-geneartion Gaussian Process optimizer (mgGPO)
%created by X. Huang, 6/18/2019
%
global g_mum
if isempty(g_mum)
g_mum = 60;
end
if nargin==5
%intialize and evaluate
% [f0,v0,gb... |
function [mu,sigma] = mixGaussAnalysis(X,c)
% Fit Gaussian Mixture Model for input data X, c classes. For simplicity
% and stability covariance are set to be diagonal.
% Input:
% X:[nxd]. n observations by d variables.
% c: no. of classes.
% Output:
% mu: [cxd]. Each row is the mean of a class.
% sigma:[dxc].
% Ini... |
function [ KMatrix ] = SingleVectorCameraModel( Parameters )
%SingleVectorCameraModel
% Builds a camera model using a single vector of Parameters and
% returns the resulting K-Matrix in KMatrix.
% There must be 8 parameters passed ordered as
% (1) ChipWidth - An integer describing the number of horizontal pixels.
%... |
function this = initiateExperiment(this, dataset)
this.dataset = dataset;
observables = filter(this.dataset, @isObservable);
for i = 1:length(observables)
df = observables{i};
name = df.name;
this.ref.(name).obs = 1;
this.ref.(name).dataIdx = df.index;
end
% save observable indices (states, rea... |
function [var_endo, var_mid, var_epi] = CycleAvg(test, var)
CPP = [40 ,60, 80, 100, 120, 140];
for i = 1:length(CPP)
eval(['SubendoVar = test.Results{1,',num2str(2*i-1),'}.',var,'3;']);
eval(['MidVar = test.Results{1,',num2str(2*i-1),'}.',var,'2;']);
eval(['SubepiVar = test.Results{1,',num2str(2*i-1),'}.',var,'1... |
classdef NdgNonhydrostaticSolver1d < NdgAbstractNonhydrostaticSolver
%NDGNONHYDROSTATICSOLVER1D 此处显示有关此类的摘要
% 此处显示详细说明
methods
function obj = NdgNonhydrostaticSolver1d(PhysClass)
obj = obj@NdgAbstractNonhydrostaticSolver(PhysClass);
obj.matSet... |
%record.
recObj = audiorecorder;
disp('Start speaking.');
recordblocking(recObj,2);
disp('End of Recording.');
y = getaudiodata(recObj);
%%
Fs = 9000;
soundsc(y);
%%
Fs = 9000;
x = zeros(1000,1);
x(1) = 1;
x(1000) = 1;
z = conv(x,y);
%frequency domain
[b,a] = butter(3,[0.05 0.55],'bandpass');
filteredY = filter(b,a,y)... |
clear; close all; clc
%%
iris=load('data\iris.txt'); %Training data
pi = randperm(size(iris, 1));
Y=iris(pi,5); X=iris(pi, 1:2);
X = iris(:, [1, 2]); y = iris(:, 5);
%% ============A: Plot Iris Data==========%%
one = find(y==0);
two = find(y==1);
thr = find(y==2);
scatter(X(one, 1), X(one,2), 'g'); hold on
scatter(X... |
%training set in the range of [-1, 1]
x=-1.0:0.05:1.0;
% generating training data, the desired outputs
y=1.2*sin(3.14*x)-cos(2.4*3.14*x);
%Number of Training examples
train_num = length(x);
epochs = 1000;
% 2. Construct and configure the MLP
net = patternnet(20);
net.divideFcn = 'dividetrain'; % input for training o... |
colorImage = imread('colorIm3.jpg'); %Choose one of the three included 'colorIm' files
imgR = colorImage(:,:,1);
imgG = colorImage(:,:,2);
imgB = colorImage(:,:,3);
% make gray scale images
gimgR = mean( imgR, 3 ); mean1 = mean(gimgR(:));
gimgG = mean( imgG, 3 ); mean2 = mean(gimgG(:));
gimgB = mean( imgB, 3... |
function [ S ] = fsym( X )
%S = [X,X(:,end-1:-1:2); X(end-1:-1:2,:), X(end-1:-1:2,end-1:-1:2)];
S = [X,fliplr(X);flipud(X),fliplr(flipud(X))];
end
|
clc
clear
close all
labeltsize=35;
fw = 'normal'; %%是否加粗斜体之类
fn='Times New Roman';
linewide1=3;
mkft = 15;
load p_fc_SNR_15_1N_s0.1.mat
figure(1);
hold on
plot(fc,Pd_NMF_mc,'r','linewidth',2)
plot(fc,Pd_SCM_mc,'g','linewidth',2)
plot(fc,Pd_CC_mc,'b','linewidth',2)
plot(fc,Pd_ML_mc,'c','linewidth',2)
plot(fc,Pd_ECCT_mc,... |
function FS_rolling_schnitz(data)
[indX,B,C] = FS_schnitz(data)
lo = -0.5;
hi = 0.5;
Dat = data.undirected;
counter = 1;
figure();
for i = 1;
subplot(3,4,counter);
imagesc(normc(squeeze(Dat(i,:,indX)))');
imagesc(C);
title('AVG (UNDIRECTED)');
subplot(3,4,counter+1);
imagesc... |
function pickAnnot(source,~)
parent = source;
gui = guidata(source);
lbls = fieldnames(gui.annot.cmap);
nbeh = length(lbls);
ncol = ceil(nbeh/20);
nrows = ceil(nbeh/ncol);
colwidth = 180;
hfig = figure('dockcontrols','off','menubar','none',...
'Tag','Annot browser','NumberTitle','off');
gui.browser = hfig;
... |
% inertial.m: Animates trajectories for 5 cases demonstrating
% inertial motion. Here are the cases:
% 1. basic case: wind stress in x and y directions cyan
% of .1 Nm^-2, f=1x10^-4 s^-1, linear friction,
% mixed layer depth h=20m, no initial velocity.
% ... |
function [w,a] = LS_FastSolve(c, Q, S_diag, QTETy, y, E, Tau )
[N,DK] = size(E);
K = length(c);
D = floor(DK/K);
c_expand = reshape( ones(D,1)*c', [DK,1] );
Diag = S_diag + Tau./c_expand;
Diag = 1./Diag;
w = Q*( spdiags(Diag,0,DK,DK) )*QTETy
%w = Q*( inv( diag(S_diag)+spdiags(Tau./c_expand,0,DK,DK) ) )*QTETy;
a = ... |
clear all
spm fmri
%% DEFINE SCRIPT PARAMETERS
dir_base = '/Volumes/SAMSUNG/mvpa/functional';
sess_prfx = 'sess';
struct_FM_prfx = 'one_back'; %DIRECTORY prefix where structural and FM folders are
all_subjects = 1:21;
sub_ind_tbr_con = all_subj... |
function [Fx,Dx] = getDataSetxElectra(eeg,target_id,dxy_dataset,Nsd,G_online,fs,all)
%getDataSetx extract the dataset from the features by performig
%selected data choice by feedback delay
if(nargin < 5)
allp = false;
else
allp = all;
end
if allp == false
NFl = size(Features,1);
target_coords = double(... |
function data_deapodized = mrir_regrid_trapezoid_rolloff(data_roft, trapezoid)
%MRIR_REGRID_TRAPEZOID_ROLLOFF
%
% data_deapodized = mrir_regrid_trapezoid_rolloff(data_roft, trapezoid)
%
% deapodization
% "ice_trapezoid_rolloff.m"
% jonathan polimeni <jonp@padkeemao.nmr.mgh.harvard.edu>, 2007/jan/03
% $Id$
%********... |
%% Stelling 19
%
% Met de onderstaande code ken je de waarde 6
% aan variabele B toe.
%
% ------------code--------------
% B = 6
% ------------code--------------
%
Antwoord = NaN; % v... |
classdef nnroipool < nntest
properties
x
end
properties (TestParameter)
method = {'avg', 'max'}
subdivisions = {[1 1], [2 1], [1 2], [3 7], [16 16]}
end
methods (TestClassSetup)
function data(test,device)
% make sure that all elements in x are different. in this way,
% we can com... |
function [ P ] = cp_smbss( Y,opts )
%% CPD based on a single mode blind source separation (CP-SMBSS)
% Usage: P = cp_smbss(Y,opts);
% opts: -- a structure containing the following fields
% .NumOfComp: Rank of the output tensor
% .BSSmode: the mode on which BSS runs
% .BSSalgFile: a -mat file ... |
function duck45(beta)
[t, M] = ode45(@slope, [0,2], [0,10]);
H = M(:,1);
V = M(:,2);
plot(t,H)
function res = slope(t, X)
p = X(1); % the first component is position
v = X(2); % the second component is velocity
dpdt = v;
dv... |
%aerosonde_initialize.m
% Aerosonde UAV Initialization Routine
%
% Copyright 2002 Unmanned Dynamics, LLC
% Modified JFW using Mathworks Aerospace Blockset 2 March 2011
% For internal use only
% add ell4 path
%path(path,'C:\Documents and Settings\eh3081\My Documents\MATLAB\ATRAEAII\ell4')
%% obtai... |
% clear all
close all
rng('shuffle')
%% Initialization
N = 4;
M = 2;
P = 16;
Z = 8;
K = 1;
fa = 1e-3;
% fau = logspace(-8,-1,8);
var_n = 10^-(2);
var_c = var_n*1e3;
L = 0.5*(0:P-1)';
g = -1:1/16/Z:1;
g_ = length(g);
mu = inf;
PSL = 10*log10(log(length(g))/N);
N_ = N*P*M;
N_2 = P*M*l... |
function [val,selected] = qgetblk(A,S,I,extent,border);
%QGETBLK Get block values in a N-D quadtree decomposition.
% VALS = QGETBLK(X,S,[],EXTENT) returns the values of the blocks
% having the dimensions specified in the vector EXTENT in an N-D
% array whose last dimension indexes the blocks.
%
% [VALS,I] = QG... |
function roomType()
bedroom =
bathroom =
diningRoom =
livingRoom =
kitchen =
mudroom =
nursery = |
L=im2bw(rgb2gray(sam2),0.7);
imshow(L);
imageSize=size(L);
[xx,yy] = ndgrid((1:imageSize(1))-300,(1:imageSize(2))-400);
mask = (xx.^2 + yy.^2)<250^2;
mask=mask;%.*(zeros(imageSize(1),imageSize(2))+1);
%imshow(mask);
K=L.*mask;
%imshow(K); |
options.number = 1;
options.meancorrection = 0;
%% 1 When Pearson of Mean works
X = [
-3 -2
-2 -3
3 2
2 3
];
Y = X;
X1=dimreduction(X,'svd_ndir',options);
Y1=dimreduction(Y,'svd_ndir',options);
corr(mean(X,2),mean(Y,2))
corr(X1,Y1) % X1,Y1 projections along y=x
figure,
subplot(1,2,1); ... |
function Out = RemoveCharacterDriver(In,Target)
if(numel(Target) == 1)
Out = RemoveCharacterSingle(In,Target);
else
Out = RemoveCharacterGroup(In,Target);
end
Out = deblank(Out);
end |
theta = 0:0.01:2*pi;
for i = 0.1:0.1:2
rho = (pi/2)*((cos(theta+pi)+1)/2)*i;
polarplot(theta,rho);
hold on;
end |
function ind = lowerBound(haystack, needle, varargin)
% lowerBound(haystack, needle, varargin)
% unpack arguments
if nargin < 4
hi = length(haystack);
if nargin < 3
lo = 1;
else
lo = varargin{1};
end
else
lo = varargin{1};
hi = varargin{2};
end
hayleng = hi;
% binary search for t... |
function [fps, period, relerr] = andor_fps(namepattern, varargin)
%function [fps, period, relerr] = andor_fps(namepattern, varargin)
%calculates the fps and its inverse the inter-frame period of an andor sif
%file. Only the first frames are used for this calculation. They are
%assumed to be equidistant.
%
%input: filen... |
function [stack_unfold] = unfold_stack(stack)
numlayers = 2*length(stack);
stack_unfold = cell(1, numlayers);
for l = 1:numlayers
if l > numlayers/2
stack_unfold{l}.W = stack{numlayers -l + 1}.W';
stack_unfold{l}.b = stack{numlayers -l + 1}.a;
else
stack_unfold{l}.W = stack{l}.W;... |
function [mdl_target_background, mdl_car_truck, featureSapace] = initialize_models(params)
% TODO: Add explicit explanations here
if(params.isAnnotated == true)
load([params.annotationLocation , params.annotationFileName], 'annotation');
else
annotation = annotate_data_set(params.isVideo, params.datasetLocat... |
%Elman Application
%
clf
figure(gcf)
setfsize(500,500);
echo on
% MEWELM —— 建立一个Elman神经网络
% TRAIN —— 训练一个神经网络
% SIM —— 对一个神经网络进行仿真
pause %Strik any key to creat a network
clc
P1=sin(1:20);
P2=sin(1:20)*2;
T1=ones(1,20);
T2=ones(1,20)*2;
P=[P1 P2 P1 P2];
T=[T1 T2 T1 T2];
Pseq=con2seq(P);
Tseq=con2seq(T);
R=1; %1 i... |
function [ out ] = parse_midi(path)
fid = fopen(path);
tempo = 0.5;
[ len, div ] = parse_header(fid);
out = {};
for i = 1:len
magic = fread(fid, 1, 'uint32=>uint32', 'b');
if magic ~= 1297379947
error('bad format %d', magic);
end
fread(fid, 1, 'uint32');
... |
clear
clc
A = [9 9 9 9]; %First number in vector representation
B = [1]; %Second number in vector representation
C = AddMN(A,B); %Calculate sum of A and B
disp(['Sum of ' DispMN(A) ' and ' DispMN(B) ' is ' DispMN(C)]);
A = [1 0 0 0 0]; %First number in vector representation
B = [1]; %Second number in vector represent... |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%README:
%This function initialises the boundaries of the optimisation variables of
%system 13/17. Qmin and Qmax consist of the Q boundaries of wtg and pv strings
%%respectively. The boundaries are appended with the boundaries of the
%%transfor... |
function [endpoint,integrand] = planar_cost(sol)
endpoint = 0;
q_min = [-64, -107, -165] * (pi/180);
q_max = [124, 158, 165] * (pi/180);
qp_min = -1*[57, 114, 360] * (pi/180);
qp_max = [57, 114, 360] * (pi/180);
u_min = -1*[4.64, 2.0, 0.29]*50;
u_max = [4.64, 2.0, 0.29]*50;
q11 = (2*sol.states(:,1) - (q_ma... |
function [outputArg1,outputArg2] = instrumented_demo(inputArg1,u)
assignin('base','run_info',sprintf('%sOND#%f$',evalin('base','run_info'),u(2)));
outputArg1 = inputArg1;
outputArg2 = u;
end
|
clear
a1 = uint8(120)+9 %注意u和沒u的差別
whos a1
% a2 = int8(120)+int16(250) %兩個資料精度不一樣無法運算
a3 = int16(120)+int16(250)
whos a2
a4 = 10^10
whos a3
class(a3) %判斷資料型態
ch1 = 'A'
class(ch1)
v1=double(ch1)
ch2 = 'ABCD'
v2=double(ch2)
ch3='abc'
v3=double(ch3)
class(v3)
v4=char(65)
class(v4)
v5=char(65:80) |
%%% TW-WS Calculation and Plotting
% Updated 11/9/2015 Author: ---
parameters;
dragpolarPDR;
BFL = S_EWR; %Balanced field length (BFL) (ft)
TOP = BFL/37.5; %Take-off parameter (TOP)
T_W_takeoff = W_S/((rho_EWR/rho_SL)*CLmax_climb*TOP);
|
function result=cubicKernel(X,X_n,h)
rows=size(X_n,1);
d=size(X_n,2);
%Cube kernel uses param h
X_new=repmat(X,rows,1);h_new=repmat(h,rows,1);
Z=((X_new-X_n)./h_new);
Ind=(sum(abs(Z)>0.5,2)~=0);
result=(sum(Ind==0)/h(1,1)^d)/rows;
end |
function [ H ] = forward( joint, myrobot )
% Implement the forward kinemetic sovler given joint angle and
% robot definition
l1 = myrobot.link{1};
l2 = myrobot.link{2};
l3 = myrobot.link{3};
l4 = myrobot.link{4};
l5 = myrobot.link{5};
l6 = myrobot.link{6};
H1 = getA(joint(1), l1.alpha, l1.D, l1.A);
H2 = getA(... |
function z=fp_wft2a(type,f,sigmax,wxl,wxi,wxh,sigmay,wyl,wyi,wyh,thr)
%FUNCTION
% z=fp_wft2a(type,f,sigmax,wxl,wxi,wxh,sigmay,wyl,wyi,wyh,thr)
%
%PURPOSE
% 2-D WFT [Analytical version]
%
%INPUT
% type: 'wff' or 'wfr'
% f: 2-D input signal
% sigmax: sigma of the window in x, recomended trial value: 10
%... |
function [pairs] = rand_unique_pairs(N, pair_num, ordered, self_pair)
% This function randomly generates unique integer number pairs
% either ordered or unordered.
%
% Input arguments:
% N: defines the range of the numbers (from 1 to N)
% pair_num: the number of pairs
% ordered: 1 for ordered pai... |
function W = WDF2_rank(t,rank)
MI = WDF2MI2(squeeze(t(:,:,1)),5);
for i = 2 : rank
MI = MI + WDF2MI2(squeeze(t(:,:,i)),5);
end
W = WDF2MI2(MI,1);
end |
function [output] = reduceWidth_greedy(im, numPixels)
%imshow(im);
%hold on;
for z =1:numPixels
output=[];
im_gray=rgb2gray(im);
energy=energyfunc(im_gray);
% start from the top, pick the smallest energy gradient, and go
% down from there. keep picking the sm... |
function [c,num_clust, mat]=get_merge(c,u,data)
%% core procedure for mergeing in aLgorthm 1
u_ =ind2vec(u); num_clust=size(u_,1);
if ~isempty(c)
c=getC(c,u');
else
c=u';
end
% can compute mean very fast uptill more than 5 million clusters.. othe... |
function [ val ] = sampleNeumann( M, x, y, z )
px = x;
py = y;
pz = z;
if(px < 1) px = 1; end
if(py < 1) py = 1; end
if(pz < 1) pz = 1; end
if(px > size(M,1)) px = size(M,1); end
if(py > size(M,2)) py = size(M,2); end
if(pz > size(M,3)) pz = size(M,z); end
val = M(... |
%% Grassland Pa5 Parameter samples 60
%% Bootstrapping On Grids
%% Sort For Bootstrap samples
ngrid=418;
nreps=80;
finalgrouprankgppv7aipa5s60bs80=zeros(nreps,12);
finalgridportiongppv7aipa5s60bs80=zeros(nreps,12);
for irep=1:nreps
tempgrouprank=zeros(ngrid,12);
for ns=1:ngrid
tempgrouprank(... |
clear;
%tic
I = im2double(imread('images/castle.jpg'));
I = attachPositionToImage(I);
%J = removeObject(I,'v',1);
J = resizeImage(I,-100,-50,1);
figure
title('original image')
imshow(I(:,:,1:3))
figure
title('new image')
imshow(J(:,:,1:3));
% toc |
% %
v = VideoReader('Experiment-12 040919.avi');
% %
video = zeros(v.Height, v.Width, v.Duration * v.FrameRate);
% %
i = 1;
while hasFrame(v)
% %
rgb = readFrame(v);
video(:,:,i) = double(rgb(:,:,1))./double(rgb(:,:,2));
% %
i = i + 1;
% %
end
video (video < 15) = 0;
Fs =... |
% Class function
% Function: updateData
% Add data from the table
function addError(self, plotNum, errorY, varargin)
if plotNum > 0 && plotNum <= self.N
xData = self.xdata{plotNum};
yData = self.ydata{plotNum};
if (~isempty(varargin))
range = varargin{1};
frange = fin... |
function pageRank = power_without_teleport(A)
%A = load('transition.txt', '-ascii');
i = A(:,1);
j = A(:,2);
num = 1490;
G = sparse(i,j,1,num,num);
c = full(sum(G));
k = find(c~=0);
D = sparse(k,k,1./c(k),num,num);
A = G*D;
x = ones(num,1)/num;
oldx = zeros(num,1);
while norm(x - oldx) > .01
oldx = x;
x = A*x... |
function lam = VMT_LayerAveMean(x,y)
% Computes the layer averaged mean of y over the depth range.
% Assumes the data outside the depth range have been set to NaN.
%
% P.R. Jackson, USGS 1-7-09
% Preallocate
intgrl = nan*ones(1,size(y,2));
dz = nan*ones(1,size(y,2));
for i = 1:size(y,2)
indx = f... |
clear
clc
A=[1,2,2,2;1,2,1,1;2,4,-1,-5;1,2,-3,-7];
B=[1,2,3,2];
for k=1:3
for i=k+1:4
m=A(i,k)/A(k,k);
A(i,k)=0;
B(i)=B(i)-m*B(k);
end
for j=k+1:4
A(i,j)=A(i,j)-m*A(k,j);
end
end |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% CTD: Fast, Accurate, and Interpretable Method for Static and Dynamic Tensor Decompositions
% Author: Jungwoo Lee, Dongjin Choi, and Sael Lee
%
% Version: 1.0
% Date: August 21, 2017
% Main Contact:... |
clc
clear all
close all
%% 数值例子
dim=[4,3000]; % k*N,k为数据维度,N为数据数目
Nclst=3; % 簇的数量,也就是隐变量z可能取值的个数
k=dim(1);
N=dim(2);
Aerr=1e-4; % 用于迭代终止
A0real = [0.3, 0.3, 0.4]; % z1点分布概率
Areal = [0.8, 0.1, 0.1;...
0.2, 0.7, 0.1;...
0.0, 0.5, 0.5]; % z序列转移概率矩阵
... |
% this function is used to generate N_all points according to parameters
%
% [ V_all,cone_inds,P_mat ] = generate_allpts( u_mat,alpha_vec,mu_vec,N_all,proj_label )
%
% Input.
% u_mat : (F x K) matrix; contains the basis vectors;
% alpha_vec : (1 x K) vector; contains the size angles;
% mu_vec ... |
%% MEM 423 - Mechanics of Vibration - Fall 2018
% Example 2.22) Develop a general-purpose MATLAB program, to find the free-vibration
% response of a viscously damped system. Use the program to find the response of a system with the
% following data:
clc
clear all
close
%% Data:
m= 450; ... |
function [t,g] = Beaulieu(M,K,a,Ts)
b = log(2)/(a/(2*Ts));
t = linspace(-M/2, M/2, M*K+1);
t = t(1:end-1);
t = t';
g = ( (1/Ts)*sinc(t/Ts).*( 4*b*pi.*t.*sin( (pi*a.*t)/Ts ) + 2*(b^2)*cos( (pi*a.*t)/Ts ) - b^2) )./( 4*(pi^2)*(t.^2)+ b^2 );
g = g / sqrt(sum(g.*g));
|
clc
clear
im = rgb2gray(imread('/Users/INNOCENTBOY/Downloads/videos/Imageprocessing/week6/original_cameraman.jpg'));
k1 = 1:1:size(im,1);
k2 = 1:1:size(im,2);
[k1,k2] = meshgrid(k1,k2);
%% Filter
h = (1/8 )*ones(3,3);
h(3,3)=0;
l1 = h.';
vector_h = l1(:);
vector_h = vector_h';
block_circulant_mat_H = block_circulatnt... |
function [] = reposicionar(x,y,z)
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
hold on
plot3(x,y,z,'marker','+','MarkerSize',10);
clear
%xslice = [-1.2,.8,2];
%yslice = 2;
%zslice = [-2,0];
%slice(x,y,z,handles.axes3,xslice,yslice,zslice)
end
|
function biasVal= bias(ClosePrice,nDay)
% bias 乖离率
% default nDay = 14
% 2013/3/21 daniel
% 预处理
if ~exist('nDay','var')
nDay = 14;
end
% 计算步
% Y值=(当日收市价-N日内移动平均收市价)/N日内移动平均收市价×100%
% 其中,N日为设立参数,可按自己选用移动平均线日数设立,一般分定为6日,12日,24日
% 和72日,亦可按10日,30日,75日设定。
maVal = ind.ma(ClosePrice,nDay, 0);
biasVal = 100*(ClosePrice... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.