text stringlengths 8 6.12M |
|---|
k = 10;
% rbf = table('Size', [0 4], 'VariableNames', {'Num Of SV Regression', 'SV % Regression', 'Num Of SV Classification', 'SV % Classification'}, 'VariableTypes', {'double', 'double', 'double', 'double'});
% Typical sigma (or gamma) and c
% 0.0001 < sigma < 10
% 0.1 < c < 100
% gamma = 1/2*(sigma(i))^2;
% c = [0.1... |
function [ flash ] = flash_group( data )
%FLASH_GROUP groups stroke level data into flash level data
% Flash is defined as strokes within 1 second and 25 km of each other
% flash structure is:
% [date][time of first stroke][centroid][area][duration][max
% energy][median energy][multiplicty]
% Area i... |
% Bireciprocal low-pass filter for interpolator
% Adaptor coefficients (all even coefficients are zero)
a1 = -0.068129;
a3 = -0.242429;
a5 = -0.461024;
a7 = -0.678715;
a9 = -0.888980;
sfgb = [];
sfgb = addoperand(sfgb, 'in', 1, 1);
sfgb = addoperand(sfgb, 'twoport', 1, [2 5], [6 3], a3, 'symmetric');
sfgb = addopera... |
function rgbvecs = RGBvectorise(im)
%RGBVECTORISE take a 3D image matrix and make it so each channel is a
%column vector. This means that each row is an RGB pixel
rgbvecs = double(reshape(im, [size(im,1)*size(im,2) 3]));
end
|
% 产生新的图像显示框
% hAxe=axes('Parent',gcf,... % 设置新的axe, 将'parent' 属性设置为当前窗口gcf
% 'Units','pixels',... %设置单位为pixels
% 'Position',[30 80 1850 885]); % 指定axe的位置,格式为[left bottom width height], left和bottom设定了axe的左下 %角坐标,width和height设定了窗口的宽度和高度
% h = figure;
% set(gcf,'outerposition',get(0,'screensize'));
% clf(h)
% i... |
function t = weightedShortestPathToAnchor(t)
%t = weightedShortestPathToAnchor(t)
%
%This function finds the shortest path from each node to all of the anchor
%nodes. then, it gives the node the position with the lease error given
%those distances (using least squares). This algorithm weights the effect
%of eac... |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%This function reads the DWI Dicom file and the gradients table csv file,
% and converts the input raw DWI data to the NRRD format with proper tags.
% Input: 'input_dwi_dicom_dir' input DICOM directory
% : 'input_dwi_header_fn' name of t... |
% force edges in delaunaytri triangulation
%
% Author: Frederic Rudawski
% Date: 25.04.2019
function triang = force_edge(triang,edges)
% shorty
T = triang.ConnectivityList;
% loop over to be enforced edges
for i = 1:size(edges,1)
% search for edge
triNr = find(sum(T==edges(i,1) | T==edges(i,2),2)==2, 1);
... |
%t = 0:0.00001:0.1;
%f = sin(2*pi*60*t)+cos(2*pi*25*t)+cos(2*pi*30*t);
%plot(t,f,'r');
fy = 'sin(2*pi*60*t) + cos(2*pi*25*t) +cos(2*pi*30*t)';
% 第一个输入变量函数是原信号函数,信号函数fy以字符串的格式输入
fs0 = 10000;
tp = 0.1;
t = -tp:1/fs0:tp; %001个样本点
k1 = 0:999;
k2 = -999:-1;
m1 = length(k1);
m2 = length(k2);
f = [fs0*k2/m2,fs0*k1... |
function neighbour_points_list_of = ...
Neighbourhood_4_points_for_2D_images( two_d_points, binary_slice )
%This gives the neigbouring points on a 2D images - we will assume a four
%neighbouring points
%The inputs are in the ini the form of n by 2 and the binary slice i.e.
%where the image come from
%The ... |
% EJERCICIOS RESUELTOS DE VISIÓN POR COMPUTADOR
% Autores: Gonzalo Pajares y Jesús Manuel de la Cruz
% Copyright RA-MA, 2007
% Ejercicio 7.3: Extracción de bordes, regiones y puntos de interés
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 7.7.3 Bordes: operador de Prewitt
%%%%%%%... |
clearvars
rosshutdown
rosinit
%while(1)
sub = rossubscriber('/tb3_0/camera/depth/image_raw');
pause(1);
msg2 = receive(sub,10);
%convert from ros image type to matlab image type
img = readImage(msg2);
p_x = 305;
p_y = 231;
depth = img(p_x,p_y);
sub2 = ross... |
function plotRoute(rcvpkts)
% Plots the routes of successful tranmissions
global SN;
global plotState;
if isempty(plotState)
initPlotState;
end
routeColor = ['y' 'm' 'c' 'r' 'g' 'b' 'w' 'k'];
figure(plotState.SNfignum);
hold on;
%remove stale packet tranmission routes
if ishandle(plotState.route) delete(plotStat... |
format long g;
data_3 = xlsread('/Users/kunpenghao/Desktop/EE_608/Project/tranportation_data.xlsx', 3,'B1:H22');
Aeq = [ones(1, 22), zeros(1, 112);
zeros(1, 22), ones(1, 22), zeros(1, 90);
zeros(1, 44), ones(1, 22), zeros(1, 68);
zeros(1, 66), ones(1, 22), zeros(1, 46);
zeros(1, 88), on... |
function [Failure, Loc, Z, dg_dx] = Stress(AC,U,X,cNode,Xea,Yea,dcNode,dXea,dYea,DV,DP)
global Adjoint
plotoption =0;
ModeNum = AC.Wing.Airfoils.ModeNum;
nT = AC.Structure.nT;
yT = AC.Structure.yT;
nAirfoil = AC.Wing.Airfoils.nAirfoil;
yAirfoil = AC.Wing.Airfoils.yAirfoil;
nNodea = AC.FEM.nNodea;
nEl... |
classdef Person < handle
properties
ID;
Name;
Age;
Gender;
Home;
Time;
x;
y;
Location;
State;
HasBeenSick;
SusCells;
InfCells;
VirLoads;
MaxInfLev;
end
methods
function p = Pers... |
function [targ, miss, r_err,r_err2, curr_dist]=Exp2_samps(llk_curr,xr,yr,xt,yt)
% Given llk, sample whether targ, miss or rand, and also how far from targ
numObj=size(llk_curr,1);
% Sample from llk
llk_norm=llk_curr./repmat(sum(llk_curr,2),1,numObj+3);
randNum=rand(numObj,1);
randsel=sum(cumsum(llk_norm,2)<repmat(rand... |
% 2D LSM for a prescribed velocity field based on upwinding
% http://www.math.lsa.umich.edu/~psmereka/LEVELSET/levelsetcodes.html
% Retrieved May 2016,
% Modified, May 2016, Kevin Chow
%
% Grid and time parameters + setup
N=200; h=2/(N-1); dt=0.10*h; tf=1.0; nt=tf/dt;
x=-1:h:1; y=x; [X,Y]=meshgrid(x);
% Number of ... |
function [S_to] = Take_off_distance(V_stall_takeoff, V_S1, T, W_to, Cd0_takeoff, AR, e, Cl0, L_over_D, S)
% This function can be used to find the Take off distance for the aircraft.
% The INPUTS are: (ALL IN SI UNITS)
% V_stall_takeoff is the stall velocity in take off config in m/s
% V_S1 is the stall speed in... |
function match_sub = matchCorners(obj1, corner_index, obj2)
window_size = 15;
cc_map = zeros(size(obj2.getGray()));
% Get the location of the first image
obj1_corner = obj1.getPoint(corner_index);
obj1_window = getWindow(obj1.getGray(), obj1_corner(2), obj1_corner(1), window_size);
... |
function [wald_stat,df,pval] = test_invertibility(VAR)
% Granger causality pre-test for invertibility
% Dimensions
[k,n_x] = size(VAR.VAR_coeff);
p = (k-1)/n_x;
% Var-cov matrix of vec(VAR_coeff)
varcov = kron(VAR.Sigma_u,inv(VAR.X'*VAR.X));
% Selection matrix picking out lag... |
function assignment_2()
clear
clc
[Gaussian_train_class1, Gaussian_train_class2, Gaussian_test_class1, Gaussian_test_class2, circle_train_class1, circle_train_class2, circle_test_class1, circle_test_class2] = generate_data;
%% K-Means
accuracy=zeros(5,5);
for k1=1:5
for k2=1:5... |
function [ret] = publish_with_soup_2017
%% Script publish_with_soup
%
% file: publish_with_soup.m
% author: Peter Polcz <ppolcz@gmail.com>
%
% Created on 2017.08.05. Saturday, 01:28:25
%
%%
G = pglobals;
% Get active editor
active = matlab.desktop.editor.getActive;
f = pcz_resolvePath(active.Filename);
% ... |
classdef KernelRidge < BaseEstimator & RegressorMixin
% Kernel ridge regression.
%
% Kernel ridge regression (KRR) combines ridge regression (linear least
% squares with L2-norm regularization) with the kernel trick. It thus
% learns a linear function in the space induced by the respective
% ker... |
clear all;
set(gcf, 'Color', 'w');
set(0, 'defaultaxesfontsize', 20);
addpath('/Users/eadli/Dropbox/SLAC/E200/E200_waterfall/');
addpath('/Users/eadli/Dropbox/SLAC/E200/framework/E200_data');
addpath('/Users/eadli/Dropbox/SLAC/E200/E200_cher');
select_roi = 0;
header = '/Volumes/PWFA_4big';
%header = ''; % ... |
h = DS1054Z('192.168.178.129');
while true
img = h.ScreenShot();
cla reset;
imshow(img);
clear img;
end |
function [] = extractStackSpotCountsAndMasks(dataTopDir, wellPath, outDir)
% wellPath is a child (or grandchild) of dataTopDir/
cd([dataTopDir, wellPath])
dataExtractor = improc2.launchDataExtractor;
dataExtractor.extractFromProcessorData('cy.RNACounts', @getNumSpots, 'cy')
dataExtractor.extractFromProcessorData('a... |
function M = max_inv_set(P)
% MAX_INV_SET maximal invariant set.
% MAX_INV_SET(P) computes the maximal invariant set of the transition
% matrix P.
%
M = fwd_inv_set(P) & fwd_inv_set(P');
|
clear all;
% close all;
warning('off','MATLAB:scatteredInterpolant:DupPtsAvValuesWarnId');
addpath('kml_lib');
addpath('emag_lib');
addpath('plotGen');
minEle = 25; %Degrees
antHeight = 2; % m
%Simulation time
startTime = datetime(2013,11,23,12,0,0,'TimeZone','UTC');
endTime = datetime(2013,11,24,11,55,... |
function [x,iter] = cutline(fx, x1, x2, err, maxiter)
%CUTLINE 利用割线法解方程数值解
% 输入:fx 求解函数(只有一个变量) x1 x2 初值
% err 误差 maxiter 最大循环次数
% 输出:x 计算结果 iter 循环次数
syms x
iter = 0;
while abs(x1 - x2) >= err
fx1 = eval(subs(fx,x1));
fx2 = eval(subs(fx,x2));
x = x2 - fx2*(x2 - x1)/(fx2 - fx1);
x1 = x2;
x2 = ... |
purge;
%% Settings for the run
save_only_essentials = 0;
num_retrievals = 1;
% Choose how plotting interval is determined
if 0 % Plot every X seconds
plotting_criterion = 'time';
plotting_interval = 60*30; % seconds
elseif 1 % Plot every Nth generation
plotting_criterion = 'generation';
plotting... |
clear;
close all;
name = 'RESULT_7.11.2018_22_49';
path = fullfile('reconstructions',[name,'.mat']);
binNameAmp = [name,'_amp.bin'];
binNamePhase = [name,'_phase.bin'];
load(path);
ampO = abs(O);
phaseO = angle(O);
mkdir(name);
fid = fopen(fullfile(name,binNameAmp),'wb');
fwrite(fid,ampO(:),'doub... |
% readFpgaStatus( rootPath )
% rootPath - sysgen root path
%
% reports:
% FPGA build string
% uptime counter
% version
% JESD Rx Status
% JESD Tx Status
function readFpgaStatus( rootPath )
C = strsplit(rootPath, ':');
root = C{1};
axiVersionPath = [root,... |
function [theta1, theta2, theta3] = unrollingAndReshaping()
% test case uses theta1 - 10x11 matrix, theta2 - 10x11 matrix and theta3 - 1x11 matrix
% initializing matrices
theta1 = ones(10, 11);
theta2 = 2 * ones(10, 11);
theta3 = 3 * ones(1, 11);
% single unrolled vector of our parameter matrices
DVec = [theta1(:); ... |
clc;
close all;
clear;
t=-10:0.05:10;
f=1;
%31 component tringular wave
p=0;
for k=1:31
b=[((-1).^k)*[[sin(((2*k)-1)*t)]/[((2*k)-1).^2]]];
p=b+p;
end
q=p*(8/(pi.^2));
subplot(3,2,1);
plot(q);
title('tringular wave from 31 component');
%31 component saw-tooth wave
i=0;
for k=1:31
b=[((-... |
function [W]=SNF(Wall,K,t,ALPHA)
if nargin < 2
K = 4;
end
if nargin < 3
t = 5;
end
if nargin < 4
ALPHA = 1;
end
C = length(Wall);
[m,n]=size(Wall{1});
for i = 1 : C
Wall{i} = Wall{i}./repmat(sum(Wall{i},2),1,n);
Wall{i} = (Wall{i} + Wall{i}')/2;
end
for i = 1 : C
newW{i} = FindDominateSet(Wa... |
function create_cross_sections(hitran_folder,apriori_file_folder,output_root_folder,mdates,gasvec,wnrange,altcorr)
labpath = fileparts(which('calc_direct_geo.m'));
% step in Voigt calculation [1/cm]
step = 0.0005;
% wn vector
wn = [min(wnrange)-3:step:max(wnrange)+3];
% layering of the atmosphere
alt = create_laye... |
r = 0.5;
f = 220.0;
fs = 44100;
n = fs * 2;
T = (1:n) / fs;
Yp = 0;
Ym = 0;
fp = 1 / (2 * r);
fm = 1 / (2 * (1 - r));
p = r / (1 - r);
a = fm / fp;
s = 1;
if a > 1
s = 1 / a;
end
for i = 1:n
t = T(i); %mod(T(i), 2 * pi);
w = mod(2 * pi * f * t, 2 * pi);
if w < 2 * pi * r
Yp(i) = sin(w * fp) * a * s... |
function [accuracy, loss] = ComputeAccuracyAndLoss(W, b, data, labels, gamma, beta, use_bn, act_func)
% ComputeAccuracyAndLoss Compute accuracy and loss for the given data
% Input: W is the weights of a pre trained network
% b is the bias of a pre trained network
% data is the training, validation or test... |
function p_norm = calculate_p_norm(x, p)
p_norm = 0;
for i=1:length(x)
p_norm = p_norm + abs(x(i)^p);
end
p_norm = nthroot(p_norm, p);
end |
function [cos_d_ang_SVE] = ...
SVE_Constraints...
(cos_d_ang_SVE,SVE_sin_theta_m)
%------------------------------------
% Refer to Section 3.2 for details.
%------------------------------------
%___Save the sign of the cross-spectra cosine projections onto the
% orthogona... |
clear all;
close all;
clc;
%input data
A = importdata('class1.txt');
class1 = A([1:700],[1:2]); %class 1
A = importdata('class2.txt');
class2 = A([1:700],[1:2]); %class 2
A = importdata('class3.txt');
class3 = A([1:700],[1:2]); %class 3
mu_C1 = mean(class1);
mu_C2 = mean(class2);
mu... |
function checker = makechecker(img1,img2)
[r1, c1, N1] = size(img1);
[r2, c2, N2] = size(img2);
if r1 ~= r2 || c1 ~= c2 || N1 ~= N2
error('Different image dimensions.');
end
ntiles = 2;
sblock = (r1/ntiles)/2;
cmask = checkerboard(sblock,ntiles,ntiles);
cmask = (cmask > 0.5);
checker = img1;
checker(cmask ==... |
function P = rayleighpdf(x,sigma)
# P = rayleighpdf(x,sigma)
# Inputs:
# 1. x is a column vector with non-negative entries
# 2. sigma is a positive scalar
# Output:
# 1. P is a column vector having the same size as x.
# each entry of P gives the pdf of the orresponding
# entry of x according to the Rayleigh distribu... |
function [pT,pg] = planet(m,r,a)
% takes a planet's mass (in Earth masses), radius (in Earth radii), and
% planet's orbital radius (in AU) and returns the planet's orbital
% period (in Earth years) and the planet's g (in terms of Earth's g).
% calculate orbital period in Earth years
pT = a^3;
% calculate g in terms o... |
% Alamouti 2x1
%
% y=Hx+n
%
function ber = ber_spec0_21(SNR)
load precision.mat
x=zeros(1,BLOCK_SIZE);
%r=zeros(1,BLOCK_SIZE);
s=zeros(2,2);
phi=zeros(2);
x_hat1_options=zeros(4);
x_hat2_options=zeros(4);
ind_xhat1=0;
ind_xhat2=0;
y=zeros(1,2);
x_hat=zeros(1,... |
function [cycle_num] = plot_every_cycle(Data,poi,fit_model,S_period)
t_per_cycle = round(2*pi/fit_model.b1);
cycle_num = round(length(S_period)/t_per_cycle);
t_unit = 2*pi/t_per_cycle;
for i = 1:cycle_num
clearvars data_cycle
subplot(cycle_num+1,1,i);
... |
[y,Fs] = audioread('my_a.wav');
win_len = 512; %feature window
% normalize amp of wav
my_a_unit = unit_amp(y,0.3,320);
feat_win = my_a_unit(end-win_len+1:end);
y_buf = my_a_unit(1:end-win_len);
pnt = match_tail(y_buf,feat_win);
update_buf = y_buf(pnt+1:end);
%remove y offset
% update_buf = update_buf - (y_buf(pnt)-m... |
% Given a folder containing Neurologger (Nlg) data from one recording
% session, extract the event and voltage data, and save in either the
% MATLAB .mat format, or in the Neuralynx (Nlx) .nev format (for the event
% file) and .ncs format (for the raw voltage traces represented by
% analog-to-digital counts [AD cou... |
function DataNarayan = OpenNarayan(CaseNumber)
cd('/home/vincent/Documents/Research Thesis/Data');
fileName = ['Case ',num2str(CaseNumber), ' QRS Subtracted Basket Data.txt'];
fileID = fopen(fileName,'r');
formatSpec = '%f';
DataNarayan = fscanf(fileID,formatSpec);
NFrames = 4000; % number of fr... |
cd(dirs.homedir)
d2 = dir('*.mat');
% pcells = []; pcells1 = []; pcells2 = []; celldat = []; shuffdat = []; label = 'RP';
armsig = [];
numshuff = 1000;
cutoff = .34;
sscells = []; ssScells = [];
for id = 1:size(d2,1)
thisdir = d2(id).name;
load(thisdir,'times_armon_thetaof_headingarm_lap_thetahalf_all... |
function x = smoothStep(t,alpha)
% x = smoothStep(t,alpha)
%
% This function is a smooth approximation of the step function:
% t < 0 : 0
% t > 0 : 1
%
% INPUTS:
% t = matrix of function inputs
% alpha = width of the smooth transition between zero and one
%
% OUTPUTS:
% x = smooth version of the step funct... |
classdef DayTradingMiscs < handle
% 统计
% ----------------
% 朱江
properties
% 挂开
openLimitCounters@double = 0;
% 挂平
closeLimitCounters@double = 0;
% 成开
filledOpenCounters@double = 0;
% 成平
filledCloseCounters@double = 0;
end
metho... |
%%%find nearest feasible soln based on random/user parameters%%%
%%%choose type of simulation: SBR-mode or ODE-mode %%%
%%%no data required, to test whether model works%%%
%%%simulation of active pool only, backbone carbon only%%%
%%%exclude stagnant pool (which is data dependent)%%%
OFspec = OpenFLUX.OFobjSpecificati... |
% Prompt the user to select the proper source directory. The user gets
% ATTEMPTS_LEFT chances to choose an appropriate source directory. If the user
% exhausts all attempts without selecting a valid source directory, of if the
% user closes the file selection dialogue without selecting a directory, a
% default source ... |
clear all;
close all;
N=1000;
for i=1:N/2
x1(1,i)=-3.0+randn(1);
x1(2,i)= 3.0+randn(1);
end;
for i=N/2+1:N
x1(1,i)=3+randn(1);
x1(2,i)= -3+randn(1);
end;
for i=1:N
x2(1,i)=0+randn(1);
x2(2,i)=0+randn(1);
end;
% x1 = [];
% x2 = [];
%
% [ label, data ] = stpReadSvmData( 'fourclass_scale.txt');... |
function [ reward, done ,bump] = reward_fn( state,prev_state, ped_pos,prev_bump,local_step,max_steps,action)
global goal_epi
car_pos_x = state(1);
car_pos_y = state(2);
car_pos = [car_pos_x,car_pos_y];
onroad = abs(ped_pos(2))<5;
if ((car_pos_y > 5)|| (car_pos_y<-5) || (( abs(ped_pos(2))<5) && (car_pos_x>(... |
QQ = eye(3);
RR = eye(1);
K = lqr(s1, QQ, RR); |
%% Average and plot RDFs and CNs for all 3 voltages
clear
close all
load('../../../equilibration/sodium_models/eq_rdf_data')
disp('Equilibrated')
plot_rdf_cn_error_area(bin_pos(1,:), all_rdf_so, 'Sulfur - oxygen in water', 5, 1, [88, 152, 191]/255, [230, 230, 230]/255, 'RDF', 'so_rdf', 0)
plot_rdf_cn_error_area(bi... |
function [moleccm3] = ppbconv(P,T)
%converts ppb to molecules/cm^3
Av = 6.022E23;
R = 82.057;
moleccm3 =10^(-9).*Av.*P./(R.*T);
end
|
% Copyright (C) Daphne Koller, Stanford University, 2012
function [F] = NormalizeCPDFactors(F)
NumFactors = length(F);
for i=1:NumFactors
f = F(i);
dummy.var = f.var(2:end);
dummy.card = f.card(2:end);
dummy.val = zeros(1,prod(dummy.card));
% Now for each joint assignment to parents, r... |
function [snakeCompl, snakeNom, windows] = ...
update_Structures(snakeCompl, snakeConst, snakeNom, windows)
windows_array = windows.array;
len = windows.numWindows;
offset_snake = snakeCompl.offset;
amp_snake = snakeCompl.amp;
spFre... |
classdef SVMRetrainClassifier < AClassifier
%This is the Support Vector Machine classifier
%Uses matlab built in SVM functionality
properties(Access=public)
SVMmodel = [];
modelParam = [];
applyZeroMean = 0; % 1 = remove mean and apply unity covar before training and testing
... |
% Homework 7 Part 3
% Polyphase Filter
% Macky McWhirter
clear all;
close all;
% Toneramp
toneramp = audioread('toneramp.wav');
% Sampling Frequency
fs = 48000;
fs2 = 8000;
% FIR filter
b = fir1(119,0.16);
toneramp_filter = filter(b,1,toneramp);
% Frequency Response of Anti-aliasing Filter
figur... |
% This script explores the transfer function, tf() in Matlab.
clc;
clear;
g = 9.8;
M = 0.5;
m = 0.5;
b = 0.1;
L = 0.3;
I = 0.006;
q = (M+m)*(I+m*(L^2))-((m*L)^2);
num = [m*L/q 0 0];
den = [1 b*(I+m*L^2)/q -(M+m)*m*g*L/q -m*g*L/q 0];
Hs = tf(num, den) |
%% Matlab for Brain and Cognitive Scientists
% Matlab code for Chapter 16
% Mike X Cohen
%
% This code accompanies the book
% "Matlab for Brain and Cognitive Scientists" (MIT Press, 2017).
% Using the code without following the book may lead to confusion,
% incorrect data analyses, and misinterpretations of res... |
function u = stokeslet_direct(x, f, box)
N = size(x, 1);
MATLAB = 0;
if(MATLAB)
u = zeros(N, 3);
for target = 1:N
source = [1:target-1 target+1:N];
rvec = bsxfun(@minus, x(target, :), x(source, :));
ri = 1./sqrt(sum(rvec.^2, 2));
rdotf = sum(rvec .* f(source, :), 2);
u(target,:) = sum( ...
b... |
function fileConverter(directory, sourceFileType, targetFileType)
% converts files of one type into another
if ~exist('directory', 'var')
directory = 'C:\Documents\MATLABResults\script41_fullseg_varyingnormalization3\newfolder\';
targetDir = 'C:\Documents\MATLABResults\script41_fullseg... |
% calculate rate of OH + 1-C3H7ONO2 -> products
% Updated 7/14/06 AEP
% Based on JPL Data Evaluation #15
% rate=kOH1C3H7ONO2(T,M)
% n-propyl nitrate
function j=kOH1C3H7ONO2(T,M)
j=7.1e-13.*exp(-1900../T); |
%% loss_2dPIH.m
% *Summary:* Saturating part of impedance learning loss funtion.
% the loss is $1-\exp(-0.5*d^2*a)$, where $a>0$ and $d^2$ is the squared
% difference between the actual and desired position of the tip of the
% outer pendulum. The mean and the variance of the loss are computed by averaging over the
% ... |
% Pyramid script
clear all
pyr = readtable('Lombardia_Pyramid');
pyr = table2array(pyr(:,2:3));
age = 0:5:100;
age = age';
pyr = [age pyr];
M = pyr(:,3);
F = pyr(:,2);
N = sum(M+F);
M = (M/N)*100;
F = (F/N)*100;
figure%('Position',[205 430 560 656])
hold on
a = bar(age,M,'hist');
b = bar(age,-F,'hist');
% a = bar(M1... |
% Helper script for converting all debates into one continuous debate using
% cell arrays. Each debate is concatenated together.
data2 = data_iccleanedB;
% Transfer trials and times from data2 to data3.
k = 1;
for index = (length(data3.trial) + 1):(length(data3.trial) + length(data2.trial))
if (k ~= length(data2.t... |
function index_folds = GeneratesKFoldsIndexes(M, k)
%% Variáveis
%Tamanho de cada fold
n = ceil(M/k);
%% Mistura os indices
indexes = randperm(M);
%% Gera os folds
index_folds = buffer(indexes,n)';
end |
a=arduino('COM5')
a.pinMode(13,'output')
|
% This fuction finds the time stamp for a sequence of frames
% ImagePath : is the path of the folder mcontaining the frames
% ImageType : is the type of images (e.g. ImageType = 'bmp')
% Y = is vector containing the time stamps
function [Y] = ImgTimeStamp(ImagePath, ImageType)
if ImagePath(end)=='\'
ImagePath = Im... |
y0 = [1,1,0.5];
r1 = 0.5;
r2 = 1;
b = 1e-3;
mu = 0.2;
[t,y] = ode45(@(t,y) f(t,y,r1,r2,b,mu),[0 10^7],y0);
propf1 = y(:,1)./((y(:,1) + y(:,2)));
d = propf1;
propf2 = y(:,2)./((y(:,1) + y(:,2)));
prop1 = (propf1+y(:,3))./(y(:,1)+y(:,2)+y(:,3) + 1-y(:,3));
prop2 = (propf2+(1-y(:,3)))./(y(:,1)+y(:,2)+y(:,3) ... |
e= sqrt(10^-16)
format long
1+e^2
A=[ 1 1 1
e 0 0
0 e 0
0 0 e]
n=3;
% Classical gram schmidt
R=zeros(3,3);
Q=A;
for j=[1:n]
v = A(:,j);
for i=[1:j-1]
R(i,j) = Q(:,i)'*A(:,j);
v=v-R(i,j)*Q(:,i);
end
R(j,j)=norm(v,2);
Q(:,j)=v/R(j,j);
end
Q
for j=[1:n]
for i=[1:j-1]... |
%%Modulation
Fs = 100;
Fc = 40;
Fm=40;
t = (0:2*Fs+1)'/Fs;
x = cos(2*pi*Fc*t);
signal = sin(2*pi*Fm*t);
m = signal*Am;
x_modulated = cos(2*pi*Fc*t + phasdev*m);
%%Adding Gaussian noise
rx = awgn(x_modulated,snr,'measured');
%%Demodulation
y = pmdemod(rx,Fc,Fs,phasdev);
... |
% Sample 12
Domain.InputVertex = [ 0 0
5 0
5 5
0 5
1 1
4 1.25
1 1.5
4 4
4 3.5
1 3.75];
Domain.Boundary.Values = 1:4 ;
Domain.Holes.Hole(1).Values = 5:7;
Domain.Holes.Hole(2).Values = 8:10;
Domain.Segments.Segment(1).Values = [4 10];
Domain.Segments.Segment(2).Values ... |
classdef descGist
%DESCGIST Descripteur d'images GIST
% dédié aux scènes extérieures
% variables Statiques
properties (Constant)
nbOri = 6; % nombre d'orientation de filtres
nbScales = 5; % nombre d'échelles de filtres
gridSize = 4; % taille de la grille de filtres
... |
function changeTimeUnits(source,~)
gui = guidata(source);
textbox = gui.ctrl.slider.text;
currentStr = textbox.String;
toFrames=0;
if(~isempty(strfind(currentStr,':')))
toFrames = 1;
end
if(toFrames)
frNum = round(getTime(currentStr)*gui.data.annoFR);
textbox.String = num2str(frNum);
textbox.Tag = 'f... |
% grade is the thickness u wanna see (ex: 90 or 95)
function plot_colorplot(title1,plotvector,grade, caseNum, parameter,EMP,toggle_thicknesslines)
global upper_speed lower_speed x y
h = pcolor(EMP(caseNum).X,plotvector(caseNum).Y,plotvector(caseNum).(char(parameter)));
title(title1);
set(h,'EdgeColor','none')
co... |
function processed_data = crefavg_mouse1(data,correction)
% Process the data to do Common Reference Averaging (CRA) i.e. subtract the
% median from each channel across all time from itself and then subtract the median at each time point across all channels from every channel.
%>>Input>>
%data - The data that you want t... |
clear
N = 200;
M = randn(N,1);
X = sign(M);
a = 5.24;
M = M + a.*randn(N,1);
M = [M];
X = (X+1)./2;
COV = randn(N,1) + 0.1.*M;
% b = 0.01;
% c = 0.01;
% Y = c.*X + b.*M;
Nboot = 2000;
output = zeros(2,2,Nboot);
[b_logregPE] = subfnLogisticRegress(X,M);
[S] = subfnLogisticRegressStats(X,M)
%%
[S] = subfnLogisticRegre... |
% Loading the trained CNN
cnn = load('cifar-experiment/cifrcnn.mat');
% Loading and merging images in different batches
batch1 = load('cifar-10-batches-mat/data_batch_1.mat');
batch2 = load('cifar-10-batches-mat/data_batch_2.mat');
batch3 = load('cifar-10-batches-mat/data_batch_3.mat');
batch4 = load('cifar-10-batches... |
function makeTexture_WarpedGrating
%generate a grating that takes into account changes in distance from eye
%for a large screen
global Mstate screenPTR screenNum
global Gtxtr Masktxtr %'playgrating' will use these
%clean up
if ~isempty(Gtxtr)
Screen('Close',Gtxtr); %First clean up: Get rid of all textures/... |
function [ ] = plotTradePnl( obj )
%PLOTTRADEPNL Summary of this function goes here
% Detailed explanation goes here
% ÅËÆä³¬£¬20140709£¬V1.0
obj.prune();
pnl = obj.data(:,obj.pnlI);
pnl = pnl(1:2:obj.rcdNum);
h = bar(pnl);
title('PNL by Trade');
xlabel('Trade No');
ylabel('PNL');
set(h,'FaceColor','c');
set(h,'Ed... |
classdef TidalWave2d< SWEConventional2d
%WINDDRIVENFLOW 此处显示有关此类的摘要
% 此处显示详细说明
properties ( Constant )
%> channel length
ChLength = 24000;
ChWidth = 1200;
%> channel depth
H0 = 30;
%> start time
startTime = 0;
%> final time
final... |
function [] = converteSVM(arquivo, nome)
dados = load(arquivo);
%dados = arquivo ;
nome = strcat(nome, '.SVM');
fid = fopen(nome,'w');
[l, c] = size(dados);
labels = dados(:, c);
for i = 1 : l
fprintf(fid, '%d ', labels(i,1));
for j = 1 : c -1
fprintf(fid, ' %i:%f', j, dados(i,j));
end
fp... |
function values = values_multiagent(alphaMB, alphaHabit, betaMB, betaHabit, betaCsus, betaBias,ratdata)
% Likelihood function for a multiagent model in the twostep task. Includes
% planning, habits, novelty preference, and bias
% Determine whether congruent or incongruent is the common transition
pCong = ratdata.p_c... |
function [epInSampleIndex, epInFrameIndex, soundSegment, zeroOneVec, volume, entropy, ve] = epdByVolEntropy(wObj, epdPrm, plotOpt)
% epdByVolHod: EPD based on volume and HOD (high-order difference)
%
% Usage:
% [epInSampleIndex, epInFrameIndex, soundSegment, zeroOneVec, volume, hod, ve] = epdByVolHod(wObj, epdPrm, plo... |
% umat for simplified example
function [stress,statev,ddsdde] = umat(stress,dstran,stran,statev,ddsdde,time)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Intialise elastic and plastic trial strains
eps_e = statev(1:6) + dstran;
eps_p = statev(7:12);
% Initialise accumulated plastic trial ... |
% nhood : Neighborhood selection
%
%
% TMH/2005
%
function [inhood,order_list]=nhood(pos_known,pos_est,options);
if ~isfield(options,'max')
options.max=Inf;
end
if isinf(options.max)
inhood=1:size(pos_known,1);
order_list=inhood;
return
end
nknown=size(pos_known,1);
... |
clear all
close all
clc
%%
load('StatTable.mat')
%% iEMG Paretico
% test dati non accoppiati
noEXO_0 = Table4Stat.iEMG_meanPar(Table4Stat.EXO == 0 & Table4Stat.Trial == 0 ,:);
EXO_0 = Table4Stat.iEMG_meanPar(Table4Stat.EXO == 1 & Table4Stat.Trial == 0 ,:);
[p0,h0,stats] = ranksum(noEXO_0,EXO_0)
% differ... |
function y = Cal_E1(SPIN1,H)
global L;
E = 0;
for i = 2:L+1
for j = 2:L+1
E =-(SPIN1(i,j)*SPIN1(i-1,j)+SPIN1(i,j)*SPIN1(i+1,j)+SPIN1(i,j)*SPIN1(i,j+1)+SPIN1(i,j)*SPIN1(i,j-1)+SPIN1(i,j)*SPIN1(i+1,j+1)+SPIN1(i,j)*SPIN1(i-1,j-1))/2-SPIN1(i,j)*H+E;
end
end
y=E; |
clear all; close all; clc;
Train = load('train.txt');
Test = load('test.txt');
%% **** UNCOMENT THIS PART FOR USING PRINCIPAL COMPONENTS OF DATA *********
% C = cov(Train(:,2:end)); %find covariance matric
% MU = mean(Train(:,2:end))';
% [V,D] = eig(C);
%
% %Take the principal eigenvectors
% pcs = 64; %ch... |
start = readtable('/Users/zhenhu/Documents/Second_semester/CIS/Mock OR/Mock OR Data/start.csv');
%%
start = sortrows(start,1);
start = [start(:,1:3) start(:,16:19)];
start = table2array(start);
A6 = start(start(:,1)==1,:);
A1 = start(start(:,1)==2,:);
%%
time_A6 = A6(131:465,2);
W_A6 = A6(131:465,4);
X_A6 ... |
% This script will analyze the West MED and East MED time series in
% frequency space, and test for coherency between the two region.
% Start Clean
clear all
close all
clc
% If =1, save these figures
save_figure = 1;
%% Load the time series.
load ../data/pdsi.fix.MED_1.WESTMED.recenter1.mat; westmed=ave_pdsi;
load .... |
classdef (Abstract) Norm < handle
%ErrorCalculator Summary of this class goes here
% Detailed explanation goes here
properties (Abstract, Constant)
name
end
properties (SetAccess=protected)
result
end
methods (Abstract, Access = public)
[result] =... |
function Y = shift_row(A,i);
%define o sentido (1 pra direita e -1 para a esquerda);
%i sentido
%A vetor
%transforma em decimal
A_dec = zeros(16,1);
for j = 0:15
A_dec(j+1) = hex2dec(strcat(A(2*j+1),A(2*j+2)))
end
% transforma em matriz 4x4
B = reshape(A_dec,[4,4]);
%faz o shift circular para cada linha
Y0 = B(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.