text stringlengths 8 6.12M |
|---|
% PREY-EMBEDDING ALGORITHM
% LFG
clc, clear all, close all
global M MAXPreyTypes NNeighbors
%% ----------------- Generate data and dissimilarity matrix ---------------
% Generate data
ScaleBetween = [-1 1];
[X,labels] = gen_data('gaussian1',ScaleBetween);
%Dissimilarity Metric: metric
metric = 'euclidean... |
function q = virtualXmon()
% creates virtual Xmon qubits
% Copyright 2017 Yulin Wu, University of Science and Technology of China
% mail4ywu@gmail.com/mail4ywu@icloud.com
q = sqc.qobj.xmon();
q.name = 'virtualQubit';
addprop(q,'r_avg');
addprop(q,'r_jpa_pumpPower');
addprop(q,'r_jpa_biasAmp');... |
function [] = PlayStim_AG(stim,fs,PS,L, useTDT, TypePhones,fc,ear,ScaleHere)
%%This function will play a Stim once
%stim = Stim to be played
%PS = psychstarter variable
%L = level to be played at
%StimText = text displayed on screen while stim is played
%TypePhones = 'headphones' or 'earphones'
%Stim_Trig = assi... |
function [delta,Vref,Ipv_prev_out,Vpv_prev_out] = IncCond(Ipv,Iprevious,Vpv,Vprevious,Vref_previous)
% REFERENCE PAPERS:
% Trishan Esram, Patrick L. Chapman, "Comparison of Photovoltaic Array
% Maximum Power Tracking Techniques", IEEE Transactions on Energy
% COnversion, vol. 22, issue 2, June 2007.
%
% M. Lokanadham,... |
function [numsT] = lcgPRNG(n,k, seed)
%A basic linear congruential generator
%n - number of inputs
%k - Number of classes NOTE: Can only take values 2, 3, or 5 for this PRNG
%Parameters of the linear congruiential generator
a = 22695477;
c = 1;
m = 2^32;
%Set a random seed
if nargin < 3
seed = 'shuffle';
end
rn... |
%% 3DTGVNN demo on dynamic data
clear;
close all;
%% Load Data
load('../data/pincat.mat');
img = new;
img_name = 'pincat';
% load('../data/perfusion.mat');
% img = x;
% img_name = 'perfusion';
% load('../data/breast.mat');
% img = abs(data(:,1:128,:));
% img_name = 'breast';
img = abs(img);
img = img/max(img(:));
... |
function varargout = mGCS1(varargin)
% MGCS1 MATLAB code for mGCS1.fig
% MGCS1, by itself, creates a new MGCS1 or raises the existing
% singleton*.
%
% H = MGCS1 returns the handle to a new MGCS1 or the handle to
% the existing singleton*.
%
% MGCS1('CALLBACK',hObject,eventData,handles,...) cal... |
function [results,arch,result] = Nozomi_analyze_tradespace(AE, params)
%% Plot last pareto front
results = plot_results([char(params.path_save_results) '\\perfs_2_2014-02-03--10-19-13.rs']);
%% Evaluate one arch and explain results
index = 1; %Arch to evaluate (find out index by clicking on tradespace... |
function dd = doseDifference(Xr,Yr,Dr,Xe,Ye,De)
% Get the size of each dose grid
[rr, cr] = size(Dr);
[re, ce] = size(De);
% Pre-allocate dose differnce grid
dd = zeros(size(De));
% Loop over rows of De (y-axis)
for i=1:re
% Are we inside of the Dr grid?
% BTW, Y is a descending list!
if Ye(i) < Yr(... |
function Qt = getQTeleport(A, alpha)
%getQTeleport compute the transition matrix taking into account that the
%surfer might jump with a probability alpha
% Qt = getQTeleport(A, alpha) : if A is an adjancency matrix and alpha is
% the probability that the surfer jumps, then Qt is the transition matrix
n = size(A... |
% Figure_kSpace.m
%
% Plot an example figure showing the Fourier Transformed version of some random
% image. For Thesis
%
% MT Cherukara
% 16 April 2019
clear;
close all;
setFigureDefaults;
% Load data
indata = read_avw('/Users/mattcher/Documents/DPhil/Data/validation_sqbold/vs6/ASE_FLAIR_av_SE.nii.gz');
% Pick one ... |
function [dev, vq1, vq2] = run_03( d1, d2 )
%% CONVERT TO POINTCLOUD
P1 = depth2OrganizedPointCloud(d1);
P2 = depth2OrganizedPointCloud(d2);
%% ICP REGISTERATION
icp_tol = 1e-2;
disp('## run_03: Performing ICP...');
[ FP1, FP2 ] = icp_reg( P1, P2, icp_tol );
disp('## run_03: ICP Registration Complete.... |
function sbQ = quantizeAtomExp(step_amp,step_rho,step_phase,min_amp,min_rho,min_phase,sb)
sbQ(1) = linearquant(sb(1)-min_amp,step_amp) + min_amp;
sbQ(4) = linearquant(sb(4)-min_phase,step_phase) + min_phase;
if (sb(2)<0)
sbQ(2) = - ( linearquant(abs(sb(2)) - min_rho,step_rho) + min_rho );
else
sbQ(2) = linear... |
%
% 2d model of a cavity with TE fields, plot Z-directed H field
%
% The geometry
inch2meter = 2.54e-2;
mil2meter = 1.0e-3*inch2meter;
d = 10.0*mil2meter; % plane-to-plane separation
l = 500.0*mil2meter; % cavity length
a = d / 10; % radius is not used here
N = 500; % number of the segments in top and bottom
NS = 10... |
%This has to be run after importing figures, "DDManalysis_AutoFile.mlx"
% This script does
% (1) Plot Gradient of Cumulative VD, Core VD
% (2) Bad data exculded
AnimalID = [12 15 24 33 34 35 51 52 55];
%% Calculate TotalVoxelCount
TotalVoxelCount = zeros(10,10);
CumVD = zeros(9,9,33);
VDD = zeros(9,9,32);
VPD90 = zer... |
%hvtaper - issue 2.0 (15/04/09) - HVLab HRV Toolbox
%--------------------------------------------------
%[outdata] = hvtaper(indata, tStart, tEnd, mode);
% Applies cosine tapers to the beginning and end of a time history
%
% outdata = new data structure containing tapered time input history
% indata = data st... |
function main
input = dlmread('3aOutput.txt', ',');
%input = evalin('base','input');
%timeInput = dlmread('3aOutputTime.txt');
%input(4,:) = timeInput(1,:);
%output = temporalPoincare(input, 10, 6.3462)
%output = temporalPoincare(input, 1000, 0.1)
output = spatialPoincare(inp... |
% exm5_ss_stability.m
% 例5,系统稳定性判断
% 北京邮电大学,尹霄丽
% 2018年12月
syms z;
A=[0 1;-6 5];
F=det(z*eye(2)-A)
r=solve(F) |
function [ beta_asymmetric ] = find_asymmetric_chemical_potential( a, b, g )
% Find chemical potential corresponding to the nomalized asymmertric
% solution of the NLS equation: \Phi_{xx} + (\beta - U(x))\Phi - g \Phi^3 = 0
%
% INPUT:
%
% Initial estimate
beta0 = 1;
% Dependence of the asymmetric mode norm... |
%
% numConverted = changeNumberSys(num, base)
%
% @param num
% a decimal natural number which you want to chage number system
% @param base
% base of number system you want (base <= 36)
% @return numConverted
% num in number system with base base
%
function numConverted = changeNumberSys(num, base)... |
% Generated on: Dec 01, 2020
% Last modification: Dec 01, 2020
% Author: Suwon Lee from Seoul National University
function [new_control_points] = bezier_degree_elevation(control_points)
new_control_points = zeros(1,numel(control_points)+1); % Allocation
new_control_points(1) = control_points(1); ... |
function [ outputFilePath ] = generate1ScatMatrix_mie_2(outputFileName,file_path,varargin)
%generate1ScatMatrix_mie Generates a single scattering Matrix in the form
%that Jacek's GAP program expects.
% Input Description needed. Takes the same inputs as the
% writeMie3InputFile function.
%Define folders to ... |
clc
clear all
x0=0;y0=0;
x1=0;y1=1;
x2=1;y2=1;
t=0:0.1:1;
x=(1-t).*(1-t).*x0+2.*t.*(1-t).*x1+t.*t.*x2;
y=(1-t).*(1-t).*y0+2.*t.*(1-t).*y1+t.*t.*y2;
plot(x,y)
hold on
clear all
t=0:0.1:1;
x0=0;y0=0;
x2=1;y2=1;
changeRate=3;
dd=(x2-x0)/10;
xx0=x0;
yy0=y2;
xx2=x2;
yy2=y0;
x1=(x2-x0)/2-changeRate*dd+x0;
y1=(x1*yy0 - x1... |
function analyseCompatibility(app, asm)
materialGroup = strings(length(asm.components),1);
for c = 1:length(asm.components)
materialGroup(c) = asm.components(c).materialGroup;
end
for c = 1:length(asm.components)
asm.components(c).compatibility = [];
row = app.compatibility(app.compatibil... |
%this script will connect me to all the nodes in the intel testbed,
%and set them up to use PEG tools
%
%make sure you run the testbed_start_sf.pl file before starting
%this script
global TOSDIR
addpath([TOSDIR '/../contrib/SystemC/matlab'])
addpath([TOSDIR '/../tools/matlab/contrib/kamin/localizationSimulation/util']... |
clear all;
clc;
fprintf('scanning images... \n');
scan = myscanfiles();
fprintf('generating data... \n');
indexNeg = 1;
NumberOfImages = 1521 * 20;
NumberOfFeatures = 360; % Features per image
XSIZE = 32;
YSIZE = 88;
cellSize = [12, 12];
%Parameters = double.empty(NumberOfImages,NumberOfFeatures, 0);
%Labels = dou... |
function [Wfd, Fstr, iternum, iterhist] = ...
warpsmth(x, y, wt, Wfd, Lfdobj, lambda, ...
conv, iterlim, active, dbglev)
%WARPSMTH smooths the relationship of Y to X
% by fitting a monotone fn. f(x) = b_0 + b_1 D^{-1} exp W(x)
% where W is a function defined over the same range as ... |
syms x y;
%Function and Initial X_0
f = symfun(y^2-(x^2)*y - 3*y+x^4 + -x^3+2*x*y-x,[x y]);
x0=[2;2];
[xi,fxi,gxi] = newtonsmethod(f,x0,50,10^-4,0.00000000001)
|
function [z,newlab] = removeNormOutliers(X,LABEL,zthresh)
labList = unique(LABEL);
z = []; newlab=[];
for lb = 1:numel(labList)
labId = labList(lb);
XSel = X(LABEL==labId);
XSel = XSel(abs(XSel)<(prctile(XSel,95)));
XSel = XSel(abs(XSel)>(prctile(XSel,5)));
newlab = [newlab; repmat(labId,size(XSel))... |
function m = biofilm_PDE_soln(r,mu,D,xi,Jout,nondim_a)
%The script computes the biofilm PDF soln
m = (r>nondim_a).*(Jout./sqrt(mu*D)).*(besselk(0,r)./besselk(1,nondim_a)) ...
+ (r<=nondim_a).*(xi/mu - (Jout./(sqrt(mu.*D))).*(besseli(0,r)./besseli(1,nondim_a)));
end
|
function [ RankList ] = DAGRank( TaskDAG, ServerList, TransRate, UserList, UserNum, delta )
%DAGRank 对任务DAG递增排序
%思路:计算AEST(the average earliest start time)和ALST(the average lastest start
% time),基于此计算结果确定关键路径(AOE网关键路径法),从而得到排序结果
% - RankList:(1,x)每一列存储节点编号
[AEST, ALST] = TimeEstimate( TaskDAG, ServerList, TransRate... |
function output = VR(noisyImg, denoisedImg, lambda, ld, ls)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Variational Denoising Residual - compute feature for Variational
% Denoising Residual for image denoising quality assessment as defined in
% paper:
%
% =====================... |
function [exo] = indivExo_SPP(cueType, exo)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Individual data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Get the number of blocks in the session
thisBlock= exo.thisBlock;
sprintf('In this session there are: %d Blocks', length(thisBlock))
% Load each block
for blocks=1:length(thisBlock)
thi... |
function [IDX,C,sumd] = kmeans_liy( X,k,initcenter )
% 修订时间: 2012-12-27 21:28
% Input:
% X 数据,行为观察,列为变量
% k 最大的簇数目,实际的数目小于等于k
% initcenter 初始化中心
% Output:
% IDX 为列向量,表明各个数据的簇编号,为连续的整数
% C 各个簇的中心向量,每一行为一个簇的中心
% sumd 为一行向量,表示各个簇到其中心点的数值之和,可以作为误差估计
% 本函数为kmeans的快速版本,可以大规模学习
% 采用欧式距离作为度量... |
function [ distanceField] = distanceFieldByGT(BoxMIN, BoxDim, vertibrae, dfsize)
EROSION = 1;
GT = loadErodedGT(vertibrae, EROSION);
GT = im2double(GT);
[XGT, YGT, ZGT] = ind2sub(size(GT), find(GT));
BoundingMIN = [min(XGT), min(YGT), min(ZGT)];
BoundingMAX = [max(XGT), max(YGT), ... |
%% Stelling 13
%
% Het is mogelijk een bestandformaat 'table' te plotten
% in Matlab.
%
Antwoord = NaN; % vul hier het juiste antwoord in 1 (WAAR) of 0 (ONWAAR)
|
a=imread('penguin.jpg');
[m n]=size(a);
n1=input('enter the bitplane No (8,7,6,5,4,3,2,1) that to be removed');
s=255-(2^(n1-1));
for i=1:m,
for j=1:n,
Out_I(i,j)=bitand(a(i,j),s);
end
end
figure,imshow(uint8(Out_I));
|
function SDdrive = userInputSDDrive(defaultanswer)
prompt={'Enter the drive letter for the SD card:'};
name='Input SD card drive letter';
numlines=1;
answer=inputdlg(prompt,name,numlines,defaultanswer);
if ~isempty(answer) && ischar(answer{1})
SDdrive = answer{1};
else
SDdrive = 'Gg';
end |
%Author: Dominic Rüfenacht, September 2012
%Purpose: Computes tonemapping function with slope a, and centered at b.
function out = f(in, a, b)
out = 1.0 ./ (1.0 + exp(-a .*((1-in)-b))); |
function [J, rJ] = nnclass(traces,varargin)
% function [J rJ] = nnclass(traces)
%
% performs a nearest neighbor classification
% traces: [cells classes trials]
%
% MF 2011-08-25
params.repetitions = 1;
params.cells = size(traces,1);
params.frames = 0;
params.trials = 0;
params = getParams(params,varargin);
if param... |
% Testing the ANFIS classifier
% for all possible horizontal input samples
global ds_h_samples;
for i = 1:size(ds_h_samples, 1)
ans = anfis_h(ds_h_samples(i, :));
end
clear i ans; |
[CA, CH, CV, CD] = lwt2(img,'haar');
%DCD = dct2(CD);
% DCH = dct2(CH);
% DCV = dct2(CV);
DCA = dct2(CA);
%[U0, S0, V0] = svd(DCD);
% [U1, S1, V1] = svd(DCH);
% [U2, S2, V2] = svd(DCV);
[U3, S3, V3] = svd(DCA);
% [CA1, CH1, CV1, CD1] = lwt2(wimg,'haar');
% %DCD1 = dct2(CD1);
% DCH1 = dct2(CH1);
% DCV1 =... |
function G = edgeFix(matrix, row, col)
for i = 1 : col
G(1, i + 1) = matrix(1, i);
G(2 + row, i + 1) = matrix(row, i);
end
for i = 2 : row + 1
for j = 2 : col + 1
G(i, j) = matrix(i - 1, j - 1);
end
end
for i = 1 : row + 2
G(i, 1) = G(i, 2);
... |
function C=SODWsp(X,W)
% function C=SODWsp(X,W)
%
%
% Returns the sum of all weighted outer products
%
% C=A*\sum_{i,j} (X(:,i)-X(:,j))(X(:,i)-X(:,j))'*W(i,j)
Q=W+W';
ii=find(sum(Q~=0));
Q=Q(ii,ii);
X=X(:,ii);
C=-(X*(Q-spdiags(sum(Q)',0,length(Q),length(Q))))*X';
%Q=Q-spdiags(sum(Q)',0,length(Q),length(Q));toc
%C=... |
function [approx_vert,intermediate] = forward_simulate(start,action,time)
% intermediate = zeros(2,size(action,1)+1);
% intermediate(:,1) = start;
% for i = 1:size(action,2)
% theta_d = approx_vert(2);
% theta_dd = action(i) -9.8*sin(approx_vert(1)) - 0.1*approx_vert(2);
% approx_vert(... |
% Min curvature model from http://dx.doi.org/10.1016/j.compstruc.2007.04.028
track = importdata('../Git/rust_controller/data/tracks/big_track_2500.csv');
n = size(track.data, 1);
x = track.data(:,1);
y = track.data(:,2);
w = track.data(:,3);
dx = -(circshift(y, -1) - circshift(y, 1)) / 2;
dy = (circshift(x, -1) - c... |
function out=flyY120(data,roi,varargin)
%out=flyY120(data,roi)
%This script is for analyzing data in the 120 fly Y mazes. It analyzes
%flies 1 through 64 the same as before. [edit-2011.07.06 ben] and uses new
%refPoints for mazes 65-120.
dispTicks=0;
if ~isempty(varargin)
if varargin{1}==1
dispTicks=1;
... |
%%%%%%%%%%%%%%%%%%%%%%%MAIN FUNCTION TO RUN ALGORITHM%%%%%%%%%%%%%%%%%%%%%%
function [result,pin,pout] = run(img,iter,dt,alpha,flag_approx,pre_mask)
%Coded by: Romeil Sandhu
%Function: This is a 'run me' file that checks necessary information and
% sets up segmentation method. This just a matlab wrappe... |
%% Test limitazione azione derivativa
% usiamo un impianto passa-basso e applichiamo l'azione derivativa
% su y(t) invece che su e(t).
% Essendo l'uscita di un passa-basso. la derivata di y(t) è
% limitata.
% cfr. Bolzern, es. 14.1
close, clear, clc
s = tf('s');
G = 1/(s+1)^3;
Kp = 2;
Ki = 1;
Kd = 1;
Ti = Kp/Ki;
Td... |
% 디지털제어 Discrete Design 프린트 예제 코드
% Sampling Time = 1 sec으로 설정한다
clear all; clc;
s = tf('s');
z = tf('z',1);
Gs = 1/(s*(10*s+1));
Ds = (10*s+1)/(s+1);
Gz = c2d(Gs,1);
DGs = Ds * Gs;
cDGs = feedback(DGs,1);
% Gz의 pole과 zero를 알기위한 코드
pole(Gz)
zero(Gz)
rlocus(Gz)
% zeta = 0.5 , Wn =1을 의미한다 (설계 디자인으로부터 ... |
function [M2,NM2]=compute_Hist_Metric2(img1,img2,index)
img1 = double(img1)/255;
img2 = double(img2)/255;
img1 = img1 - 0.01*(img1==1);
img2 = img2 - 0.01*(img2==1);
N = length(index);
sN = 20000;
gray_level = 64;%round(N^(1/(2+alpha)));
s1 = img1(index);
s2 = img2(index);
rand('state',1);
% if sampling
% sin... |
function thresholdOpt = learnThetaMS(params,scale)
fprintf('Learning theta_MS for scale = %d \n',scale);
bestScoreThreshold = -inf;
level = find(params.MS.scale == scale);
for idxThr = 1:length(params.MS.domain(level,:)) %loop over the possible threshold values
threshold = params.MS.domain(level,idxThr); ... |
%Video 2 Particle V1.0
%code by 00ll00
%===============================
video_file='';
out_w=32;
out_h=24;
out_p='minecraft:end_rod';
out_c=[0,4,0];
f_pnum=300;%输出每帧粒子数量限制
f_r=15;%输出粒子视频帧率(<=20)
video=VideoReader(video_file);
fr=video.FrameRate;%源视频帧率
fnum=floor(video.Duration) * fr;%源视频帧数
h=video.Height;%源视频高
w=vi... |
clear all;
close all;
job_opt.name=14;
list_subject=[0, 1:3 5:12 14:20];
%list_subject=[0];
results=cell(1,length(list_subject));
for i=1:1:length(list_subject)
sched = findResource('scheduler', 'configuration', 'NeuroEcon.local')
set(sched,'SubmitArguments', '-l walltime=24:00:00')
pjob = createParall... |
function varargout = dcmddeno(varargin)
%DCMDDENO Shows de-noising tools in the Wavelet Toolbox.
%
% This is a slideshow file for use with wshowdrv.m
% To see it run, type 'wshowdrv dcmddeno'
%
% See also DDENCMP, WAVEDEC, WCODEMAT, WDEN, WDENCMP, WNOISE.
% M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 12-Mar-96.... |
% band=4:7;
Cpli=[];Cx=[];O=[];SNR=[];Cxp=[];
for i=1:numel(FT)
fprintf(num2str(i))
out=tensor_connectivity3(FT{1,i}{4},FT{1,i}{2},FT{1,i}{3},band);
% out=tensor_connectivity2(FT{1,i}{4},FT{1,i}{2},band);
% out=mean(out,3);
out=mean(out(:,:,band),3);
O(i)=mean(mean(out));
Cx(:,:,i)=topoconn_... |
function flag_theta=CheckTheta(theta, theta_cr, fai, beta, cb, ws, n0, nl, kl, rou_s, A)
%check if the Van Rhee equation will have a root with the given Shields parameter
%fai - angle of internal friction, beta - bed slope
%van Rhee (2010) suggested A=3/4 for single particles and A=1/(1-n0)¡Ö1.7
%for a continuum
delta... |
function [force]=getForce(mu,Nn,Ne,icon,lx,ly,vnew,mv)
gp=1/(sqrt(3))*[-1,1,1,-1;
-1,-1,1,1]; % Gauss points
force=zeros(2*Nn,1);
for i=1:Ne
iv=icon(:,i);
gv=zeros(2,2);
A = (0.5/ly)*(vnew(iv(1)+Nn) - vnew(iv(2)+Nn) + vnew(iv(3)+Nn) - vnew(iv(4)+Nn));
... |
% 2015.2.26 constructed by Hwang, Hsin-Te
% 2015.2.26 modified by Hwang, Hsin-Te
% 1.This function performs Maximum likelihood parameter generation (MLPG) algorithm to
% smooth ANN-mapping's output
function [converted_seq_mlpg]=generalized_MLPG_ver2(Input_seq,Cov,dynamic_flag,featureDIM)
converted_seq = zeros(featur... |
function vep_timeblocks_shorttrials
animalid = '150703';
blocks = [4,6,8,10];
penangle = 10;
% adjust the paths
basepath = ['C:\Users\Julia\work\data\' animalid '\'];
supath = [basepath 'singleunits\'];
basename = [animalid '_block' int2str(blocks(1)) '_tet'];
files = dir([supath, basename, '*.mat']);
cell = 1;
% ... |
function [img, vessel, edgeCheat, GVF] = input_segmentationTestData(fileMat, resizeOn, resizeFactor, plotOn)
load(fileMat)
vesselness = oof_3D; % or oofOfa_2D
sliceIndex = 1; % easier to display just one slice than the whole volume
% resize to speed up things
if resizeOn
for ... |
function [edges, readPoses, weights, P_xi_inv, P_delta_inv, At, A, A_full, A_2t, A_2] = readG2oDataset2D(input_file_g2o, doSortEdges)
%
%% INPUTS:
% input_file_g2o: name of the g2o file to read
% doSortEdges: if true, tries to order the edges as (0,1) (1,2) etc, putting
% odometry first and then loop closures... |
function found_partials = search_partials_freq(v, Fs, period, partials, search_ratio, search_resolution)
%UNTITLED4 Summary of this function goes here
% Detailed explanation goes here
estimated_partials = ((1:n_partials) * period).';
ratio_diff = period * search_ratio/2;
resolution = 1 / ratio_diff;
max_search_range ... |
% function check_uah_vah
%filename='wrfrst_d01_0001-01-01_00:01:00'; % wrfrst, not wrfout
%filename,height
% to validate computation of uah,vah
% run wrf with fire_print_file=1
% start matlab in em_fire
% cd to the run directory
% run this script
height=20*0.3048; % 6ft
id=10003
if(id==... |
function board=gird2Board(board,x,y,turn)
gap=50;
agentTurn=2;
head=turn*10+turn;
[pRow pCol]=find(board==head,1);
board(pRow,pCol)=turn;
%if turn~=agentTurn
% x=floor(x/gap)+1;
% y=floor(y/gap)+1;
%end
board(x,y)=head;
end |
function runme_IPM_Tomales(Modelstart,Modelstop,Cluster)
% This file describes all the code needed to run the IPM model for Tomales
% oyster data. This code was modified from that in White et al. (2016)
% Ecological Applications, so there are some legacy features that were
% necessary for that implementation that are ... |
function x=convertRotation(x,inp,out)
%CONVERTROTATION Converts units of rotation
% X=CONVERTROTATION(X,INP,OUT)
% * X is a rotation in units given by INP
% * INP are the input units of rotation (either 'rad' or 'deg')
% * OUT are the output units of rotation (either 'rad' or 'deg')
% ** X is a rotation in... |
function [f, dict] = EvaluateObjectivesRuffman(signalSeg, varDec, tabWaveletsComp, nroFObj, nroVar, nroSignals)
wavelet = tabWaveletsComp(round(varDec(1))).WaveletComp;
limiar = varDec(2);
scalingFactor = varDec(3);
shiftConstant = varDec(4);
disp(['Compression: ' wavelet ' ' num2str(limiar)]);
for i=1:nroS... |
function [y] = w2(a, avrcc, avrco, avroc, avroo, avrrvp,...
avrtvl, rcc, rco, roc, roo, tvl, rvp, i, n)
% Calcualte weight vector for each day
for j = 1:n
y(1,j) = a(1)*(rcc(i-1,j)-avrcc(i-1))./n...
+ a(2)*(roo(i,j)-avroo(i))./n...
+ a(3)*(roc(i-1,j)-avroc(i-1))./n ...
+ a... |
function [stringSudoku, debugValues] = ocrSudoku (image, dataset, ...
debugEdge, ...
debugEdgeResult, ...
debugSquare, ...
debugRegistration, ...
debugRegistrationResult, ...
debugGetCell)
[h, w, ~] = size(image);
if ~exist('debugEdge', 'var')
debugEdge = 0;
... |
function [x, lambda, k, normGradLag, fx, cx, rho, nbcall] = SQP(x0, problem, epsilon, x_inf, x_sup, maxnbiter, maxnbcall, mindx, mindf, getMsgWarn)
%the SQP algorithm searches for a minimiser x
%Input:
%x0 : first estimate of a minimiser, a column vector
%problem : it is
% - either a handle to a function 'f' which re... |
%% setup paths
rootPath = fileparts( mfilename('fullpath') );
while ~exist( fullfile( rootPath, 'setup_BCFW.m' ), 'file' )
rootPath = fileparts( rootPath );
end
run( fullfile( rootPath, 'setup_BCFW' ) );
dataPath = fullfile(rootPath, 'data', 'CONLL' );
resultPath = fullfile(rootPath, 'results' , 'conll_BCFW_hybri... |
%[s_reslice_map_3d_v3] reslices SMAP and FMAP to match slice positions of DWI
%scan.
%
%
% Last modified
% 2010.08.09
% This incorporates,
% getting corresponding slice positions of SMAP and FMAP to DWI
% reslicing of SMAP and FMAP to DWI
% 2010.08.18.
% Pack memory.
% 2010.09.22.
% Add ... |
function MAIN_PlayLive
% Set up a "playable" version of the game in MATLAB using the Java
% implementation of QWOP. Q, W, O, P keys work as usual when the window is
% in focus. R resets the game. NOTE: MATLAB key listening is patchy when
% multiple keys are pressed in short succession. Hence the behavior of this
%... |
clear all
close all
nntraintool('close');
nnet.guis.closeAllViews();
% Neural networks have weights randomly initialized before training.
% Therefore the results from training are different each time. To avoid
% this behavior, explicitly set the random number generator seed.
rng('default')
% Load the trai... |
clear
profile on
X = 3;
img_name = 'DSC_0412.jpg'; %enter image file name here
in_img = double(imread(img_name))/255;
in_img = rgb2hsv(in_img);
copy = in_img;
bandwidth = 0.1;
in_imgcpy = in_img;
if(size(in_img,3) == 3)
in_img = in_img(:, :, X);
in_img = in_img*255;
in_img = log10(in_img);
%in_img = ... |
function [averageImage, rgbMean, rgbCovariance] = getImageStats(images, varargin)
%GETIMAGESTATS Get image statistics
opts.gpus = [] ;
opts.batchSize = 256 ;
opts.imageSize = [300 400] ;
opts.numThreads = 6 ;
opts.city = 'Boston';
opts = vl_argparse(opts, varargin) ;
avg = {} ;
rgbm1 = {} ;
rgbm2 = {} ;
numGpus = ... |
function stand_data=stand(data)
%将数据进行标准化处理,输出标准化数据
zeros(size(data));
[nr,nc]=size(data);
for i=1:nr
stand_data(i,:)=((data(i,:)-mean(data))./std(data));
end |
% -------------------------------------------------------------------------
% Credit Risk Assessment Toolbox
%
% Author: D. N. Sotiropoulos (2019)
% -------------------------------------------------------------------------
% This script file provides fundamental computational... |
function dydt = odeModel(t,y, susc, prob_symp, tau, cont_mat, delta_E, gammaI, gammaA)
%ODE model
%INPUT-OUTPUT
%t -> input time
%y -> y = [S, E, I, A, R]
%susc -> susceptibility
%prob_symp -> probability of developing symptoms
%tau -> decreased infectivity for asymptomatics
%cont_mat ... |
classdef Pooling < handle
%Not implemented yet
%Pooling layer for general (feadim*numdata) data, for two dimensional data like image, see Pooling2D
properties
type
%as component in DBN
OUT;
end
methods
function self = Pooling(type)
... |
clear, clf, hold off
m = 100000; veces = 50;
ax = 0; bx = 2;
ay = 0; by = 3;
sa = 0; saa = 0;
for k=1:veces
n=0;
for i=1:m
r = rand; x = ax + (bx-ax)*r;
r = rand; y = ay + (by-ay)*r;
if (x^2/4+y^2/9) < 1
n = n+1;
px(n) = x;
py(n) = y;
en... |
% Power Flow Solution by the Power Perturbation Technique
% Copyright (c) 1998 H. Saadat
ns=0;
nbus = length(busdata(:,1));
for k=1:nbus
n=busdata(k,1);
kb(n)=busdata(k,2); Vm(n)=busdata(k,3); delta(n)=busdata(k, 4);
Pd(n)=busdata(k,5); Qd(n)=busdata(k,6); Pg(n)=busdata(k,7); Qg(n) = busdata(k,8);
Qmin(n)... |
function [Lsamps,Rsamps,ITDt,dur_real] = GetMovingNoiseBand(params)
global ChanConfigInfo %This global variable is set by the user at startup, and determines which channel is considered "contra-lateral".... taking into account the recording side, and the connections between channels and ears (i.e., this should be ro... |
% segmentar celules
I = imread('cellsegmentationcompetition.png');
[f,c] = size(I);
BW = rgb2gray(I);
%imshow(BW,[]);
whitePixs = (BW == 255);
%otherPixs = ~whitePixs;
outer_whitePixs = whitePixs & ~imclearborder(whitePixs);
BW(outer_whitePixs) = 0;
figure;imshow(BW);
B = BW > 20;
figure;imshow(B);
O = imopen(B,... |
function [subbandFrequency] = subband_frequency(centerFrequency, bandwidth, nSubbands)
% Function:
% - calculate the center frequency of subbands
%
% Input:
% - centerFrequency (f_0): the center frequency between the upper and lower cutoff frequencies
% - bandwidth (B): a measure of the wi... |
function [mval]=membresia(conjunto, tipo, xval)
mval=zeros(size(xval));
for x=1:length(xval)
if tipo==0
if xval(x) < conjunto(1) && xval(x) > conjunto(4)
mval(x) = 0;
endif
if conjunto(1) <= xval(x) && xval(x) < conjunto(2)
mval(x) =(xval(x)-conjunto(1))/(conjunto(2)-conjunto(1... |
function [TermLabels] = PIDTermLabels(N)
%PIDTermLabels creates a list of the term labels to ease interpretation of
%the PID output.
% [TermLabels] = PIDTermLabels(N) is a cellular array that contains the
% term labels for the output of the PID function. It follows the notation
% of Williams and Beer.
%
% ... |
function [] = runme_IPM_mockdata_PCLA_F15(varargin)
if(nargin>0)
scenario = varargin{1};
else
scenario = 'F0.15';
end
disp(scenario)
data_savename = strcat('mockdata_March2018/PCLA_mockdata_',scenario,'_8Aug2018'); % where the mock data are
savename = strcat('PCLA_mockdata_',scenario,'_8Aug2018'); % where... |
function [args]=fsc_train(args)
global train_data train_label test_data test_label;
poolobj = parpool();
tic;
h=waitbar(0);
for i1=1:args.maxecho
waitbar(0,h,strcat('��',num2str(i1),'/',num2str(args.maxecho),'��'));
for i2=1:args.circletimes
index=1+floor(rand(args.batc... |
function VirtualEnvironment2(block)
setup(block);
function setup(block)
block.NumInputPorts = 2; % pos, pos_dot
block.NumOutputPorts = 4; % Fe, energy
block.SetPreCompInpPortInfoToDynamic;
block.SetPreCompOutPortInfoToDynamic;
block.InputPort(1).DatatypeID = 0; % double
block.Input... |
function output = SGM(img, m)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Small Gradient Magnitude - compute feature for Small Gradient Magnitude
% for image denoising quality assessment as defined in the paper:
%
% ==============================================================... |
function x = pa2(M,N)
% function x = pa2(M,N)
%
% Proceso aleatorio nš2
A = rand(M,1)*ones(1,N);
B = rand(M,1)*ones(1,N);
x = ( rand(M,N)-0.5 ).*B + A; |
function [Mfri,MMA]=fri(results,MPHI,NAR,N,M,P,Vnames)
% results es el output de la función fvar.m de Le Sage
% MPHI son las matrices del VAR
% NAR es el número de retardos del VAR
% N es el número de variables del VAR
% M es el orden del VMA(inf). Por ejemplo 50.
% P es la matriz de factorización para calcular l... |
function desi
%desi - this is the main function for doing DESI data processing
defP = '/Volumes/JSM/DB/';
if ~exist(defP,'dir')
defP = pwd;
end
if ~strcmp(defP(end),filesep)
defP = [defP filesep];
end
% Do some simple things related to the imzML converter here...
javaclasspath('packages/imzMLConverter/imzMLCo... |
function [metrics,results] = SCHED_evaluate_architecture(sequence,params)
%% SCHED_evaluate_architecture.m
% This function takes as an input a scheduling architecture and provides as
% outputs two metric: discounted value and data continuity.\
% Usage: metrics = SCHED_evaluate_architecture(sequence,params)
% sequence ... |
function bucket = process_bucket(bucket, S, init)
%% INPUT SPECIFICATIONS:
N = numel(bucket.x);
if N == 0
return
end
% create an N x N connection matrix, set to ones
connection = zeros(N)+1;
% If two blocks are less than blockSize away, they overlap
overlap = zeros(N);
for n=1:N
overlapX = abs(bu... |
function [ Z_X, Z_B, gamma ] = l_network ( Z_0, Z_l, f, f_spectrum )
%{
George Bakirtzis <george@bakirtzis.com>
This function takes as inputs the real characteristic
impedance, Z_0, the complex load impedance, Z_l, the
frequency of operation, f, and the spectrum of frequenc... |
close all;
clear all;
freq(10)=0;
freq2(100)=0;
fs=4000;
y=wavrecord(1*fs,fs);%records the noise from mic
fp=2000;
x=wavrecord(2*fp,fp);
t=0:1/fs:1-(1/fs);
l=length(t);
gapcount=0;
N=0;
pn(l)=0; %pn sequence
m=max(y);
y2=abs(y);
y21=(y2/m)*40;
y3=floor(y21);
m=max(x);
x=abs(x);
x=(x/m)*... |
function sampleA1 = uniformSampling(A1,step)
% Function to uniformly sample from data the value at every 'step' points.
%
% Input
% A1: pointcloud
% step: sample step
% Output
% sampleA1: uniform sub-sample of A1
na1 = size(A1,2);
ndim = size(A1,1);
sampleA1 = zeros(ndim,int8(na... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.