text stringlengths 8 6.12M |
|---|
% Reprocess data after gear has been selected.
%% Demanded speed and torque between transmission and ICE/EM, for the selected gear.
etag=trn.eta(gear(task.drv)); % gear efficiency at driving segments.
ix=task.acc(task.drv) > 0;
etag(ix)=1./etag(ix); % inverted efficiency for positive demands.
rg=tr... |
function [label] = knkmeans_rbf_predict(Xtrain, Xtest, train_label, gamma, Ktrain)
%% [label] = knkmeans_predict(Xtrain, Xtest, train_label, gamma, Ktrain)
chunk = 10000;
ntrain = size(Xtrain,1);
ntest = size(Xtest, 1);
i=0;
k = max(train_label);
E = sparse(train_label, 1:ntrain, 1, k, ntrain, ntrain);
E = bsxfun(@t... |
function [event_index,event_peak,amps] = EPSP_detection(W,si,amp_thre,diff_gap,diff_thre,event_duration)
%% calculate the difference with 240us as "1st derivative" to detect event
diff_gap = diff_gap/si;
event_duration =event_duration/si;
data_s = smooth(W); %smooth the data
diff_ = data_s(1+diff_gap:end)-data_s(1:end... |
function [ Freqinfo ] = create_spectrum( fs,y )
%take sampling frequency fs and turn it into frequency in radians for scaling
%set 16 bit resolution
n = 2^16;
%compute fft with 16-bit resolution and center
Y = fftshift(fft(y,n));
%scale and center frequency bins around w=0
f = ((-n/2:n/2-1)*(fs/n)).';
%organize th... |
function B = pointCloudObject_(point_cloud)
B = struct();
% Add xyz coordinates
B.points = point_cloud(:, 1:3);
% Add normals
if size(point_cloud, 2) == 6
B.normals = point_cloud(:, 4:6);
end
% Add boundary confidence
if size(point_cloud, 2) == 4
B.boundary_confidenc... |
function ar=autocorr(vec,lag)
% returns the lag n autocorrelation
% useage: autocorr(vec,lag)
% note: lag can be either a scaler or a vector of lags to evaluate
% by default, lag = 1
if nargin<2
lag=1;
end
%aumat=xcorr(vec,vec,lag,'coeff');
%ar=aumat(end);
if length(lag>1)
for ct=1:length(lag)
ar... |
clear all
close all
% K H Richardson 29-07-21 Queen Mary University London
%%% Load sample
sample='sample.DSC';
%%% Field shift if required
% y=[240.08, 264.1, 289, 313, 337,361,385,409,432,457,481];
% x=[200, 220, 240, 260, 280, 300, 320,340, 360, 380, 400];
% p = polyfit(x,y,1);
% yfit= p(1)*x + p(2);
p=[1 0];
%... |
function [coord_vec_corrected,disp_vec] = correct_displacement_with_distortion_model_coeffs(coord_vec_1,coord_vec_2,coeff_vec)
% CORRECT_DISPLACEMENT_WITH_DISTORTION_MODEL - Corrects the displacement between two coordinate vectors with distortion model proposed by (Bing Pan et al 2014 Meas. Sci. Technol. 25 025001)
%... |
function [PC_back,cycle_back,intmem_back]=RotLeftACC(PC,cycle,intmem)
intmem_back=intmem;
ACC=intmem(225,1);
if(ACC>127)
h=1;
else
h=0;
end
intmem_back(225,1)=(ACC-h*128)*2+h;
%cycle count
cycle_back=cycle+1;
PC_back=PC+1;
end |
function [theta, J_history] = gradientDescentMulti(X, y, theta, alpha, num_iters)
%GRADIENTDESCENTMULTI Performs gradient descent to learn theta
% theta = GRADIENTDESCENTMULTI(x, y, theta, alpha, num_iters) updates theta by
% taking num_iters gradient steps with learning rate alpha
% Initialize some useful values
... |
% DW1DTREM 離散1次元ウェーブレット "Tree" モードの管理コマンド
% [OUT1,OUT2] = DW1DTREM(OPTION,WIN_DW1DTOOL,IN3,IN4)
% Copyright 1995-2004 The MathWorks, Inc.
|
function new_package = package_appender(package, object, smallest_row, smallest_col)
% Appends the package with the given object on the given postion.
% If the object dimensions exceed the dimensions of the package, a new
% one will be created which wil fit both. Empty spaces in the package
% are denote... |
classdef Keyword
enumeration
DIFF ( 'diff', '-', -1, '0', '', '*' )
DOT ( 'diff', '/', -1, '1', '', '^' )
DIFFLOG ( 'diff', '-', -1, '0', 'log', '*' )
MOVSUM ( 'mov', '+', -4, '0', '', '' )
MOVPROD ( 'mov', '*', -4, '1', '', '' )
... |
function [X, Y] = FindVertices(minX, maxX, minY, maxY, n)
%FINDVERTICES Znajduje podział kwadratu na n^2 kwadratów
% Argumenty
% - minX, minY, maxX, maxY - skalary, ograniczenia tworzące kwadrat do podziału
% - n - skalar, ile razy mniejszy ma być każdy kwadrat po podziale od
% początkowego
% Wyjścia
% X, Y - macie... |
function [NewSt, CurrReward] = ...
EnvModule(CurrState, Goal, GridSize, NoUpAvail,...
NoDownAvail, ObsInCurrTrial, Action, PathAGreatLossAt, PathBGreatLossAt,...
PathCGreatLossAt, GreatLossFreqInPathA, GreatLossFreqInPathB, GreatLossFreqInPathC,...
TrialsCount, BlockCount, NumOfTrials, CheckAvailActInB... |
% this script will convert the CSV file into MAT file under the same
% directory.
files = dir(fullfile('*.csv'))
for i=1:length(files)
[path, name, ext] = fileparts(files(i).name);
% M = csvread(files(i).name);
M = importfile(files(i).name);
save(strcat(name, '.mat'), 'M');
end |
function [ d, z ] = imtqlx ( n, d, e, z )
%*****************************************************************************80
%
%% IMTQLX diagonalizes a symmetric tridiagonal matrix.
%
% Discussion:
%
% This routine is a slightly modified version of the EISPACK routine to
% perform the implicit QL algorithm on a s... |
clear all
clc
%%
scenario_finale
%% Modello del sistema
%x(1) - coordinata x
%x(2) - coordinata y
%x(3) - coordinata teta
%x(4) - steering angle
%variabili di attuazione:
%u(1) - linear speed
%u(2) - angular speed
nx = 4;
ny = 4;
nu = 2;
nlobj = nlmpc(nx,ny,nu);
Ts=0.1;%scenario.SampleTime;
p=10;
%Vincoli di contr... |
function get_lines(DIR)
files=dir([DIR,'*.java']);
count=0;
for i=1 : length(files)
inf=fopen([DIR, files(i).name]);
while(1)
a = fgetl(inf);
if(~isstr(a))
break;
end
count=count+1;
end
fclose(inf);
end
disp(count);
end |
close all; clear;
% load 'peppers.png' (the values are given in uint8, i.e. [255,0,0]
% represents 'red')
img_rgb = imread('peppers.png');
% the HSV image can be calculated using 'rgb2hsv':
img_hsv = rgb2hsv(img_rgb);
% display the images:
figure;
subplot(1,3,1); imshow(img_rgb); title('image in RGB space');
subplot... |
% Assignment 02, Exercise 03 by Georgia Markouleki(387232), Manuel Widdel(379704), Mohammad Teimoori(370543)
function [ u ] = a02e04WaveEq(t, x, a, b)
fun = @(l) b.*l.*exp(-0.5*(l.^2));
Qarray = @(a,b)arrayfun(@(ak,bk)integral(fun,ak,bk),a,b);
u = 0.5.*((a./((x-t-3).^2+1))+(a./((x-t+3).^2+1))+(a./((x+t-3).^2+1))+(a./... |
%Exercise 16, Andrew Banman
%Constructs the homology of the Torus from a LazyWitness complexe
%with Zmod2 coefficients.
dist = ex4_torusDistances(1000);
file_name = 'lazyTorus';
coeff_dim = 2;
lazyWitness(dist,coeff_dim,file_name); |
%% Cancer Research Grand Challenge
% Workflow for processing a bunch of Waters Xevo files.
% The raw Waters files have been converted into H5 files in order to make
% them readable on a Mac computer. These files are then processed en masse
% in order to accurately determine the common peaks and then to perform
% multi... |
function [hhh]=hhh(x)
n=length(x);
i=1;
while i<n+1
m(1,i+1)=x(i);
i=i+1;
end
m(1,1)=x(1);
m(1,n+2)=x(n);
i=1;
while i<n+1
m(2,i+1)=f(x(i));
i=i+1;
end
m(2,1)=f(x(1));
m(2,n+2)=f(x(n));
i=2;
while i<n+1
m(3,i)=(m(2,i+1)-m(2,i))/(m(1,i+1)-m(1,i));
i=i+1;
end
m(3,1)=-(2*x(1))/(x(1)^2 + 1)^2;
m(3,n+1)=-(2*x(n))/(x(n)... |
classdef brick < hgsetget
%BRICK A brick object to be used in the Arkanoid game.
% This object contains the properties necessary to construct a single brick in the game.
% Properties are included for later development such as powerups and hardness. The image of
% the brick in the game is generated... |
function y = f(x)
%function y = f(x)
%define your integrand
y = 4./(1+(x.^2)); %This is for part 4A of the homework
%y = cos(x.^2); %This is for part 4B of the homework
|
function [ v1 ] = LatReduce( v1, v2 )
% Lattice Reduction
% 1. If ||v|| > ||v2||, swap v1 and v2 so that ||v1|| <= ||v2||.
% 2. Let t be the closest integer to (v1 • v2)/(v1 • v1).
% 3. If t = 0, stop. If t != 0, replace v2 by (v2 - tv1) and go to step 1
t = 1;
iter = 0;
fprintf('iter v1 v2 n1 n2 swap... |
function [X1,Y1,Z1,Ux,Uy,Uz] = plo3dUxy(file)
load(file); close all;
set(0,'defaultAxesFontSize',22); set(0,'DefaultLineMarkerSize',14)
tmp = sortrows(OutData,[3,1,2]);
[~,dataum ] = reshapeData(tmp);
X3D = dataum.X1; Y3D = dataum.Y1; Z3D = dataum.Z1;
Ux3D = dataum.Ux; Uy3D = dataum.Uy; ... |
clear;
close all;
Fs = 30000;
F1 = 300; % Hz
F2 = 8000; % Hz
n = 3; % Order of butterworth filter
t = 1:10000;
fpass = [F1 F2];
[b,a] = butter(n,fpass*2/Fs);
% N = 257;
% Impulse = zeros(1,N);
% Impulse(1) = 1;
% y = IIRLinearFilter(Impulse);
% %y = filtfilt(b,a,Impulse);
% plot(y, '.');
% figure, freqz(y);
% H = ab... |
%%
%enter the path where the file is stored in your system
path = ('D:\Research\ITLab\Transciptomics_data');
%file name
fname = strcat(path,'\transcriptome.v7pm.txt');
%%
% %we will keep this sectionc ommented out, because parsing the text files
% %takes a freakin' long time! We will simply load the data in the next ... |
%% Stelling 10
%
% In Matlab wordt een grafiek gemaakt m.b.v. de functie plot().
%
Antwoord = NaN; % vul hier het juiste antwoord in 1 (WAAR) of 0 (ONWAAR)
|
function OutStateHex = ScaledDownAESNibbleSub(InStateHex)
% OutStateHex = ScaledDownAESNibbleSub(InStateHex)
% Input: InStateHex = 2 by 2 matrix of single hex digits (i.e.,
% nibbles).
% Output: OutStateHex = 2 by 2 matrix of single hex digits (i.e.,
% nibbles), resulting from the Nibble Sub transformation of the sca... |
%clc; clear; close all;
close all; clc
global Ts SoC_Max SoC_Min C_rate_Max C_rate_Min uMax uMin StatesMin StatesMax InputsMin InputsMax Hp Q R;
filePath = matlab.desktop.editor.getActiveFilename;
fileName = filePath(find(filePath=='/',1,'last')+1:end);
proyectPath = filePath(1:length(filePath)-length(char(fil... |
function out1 = hess_grf_ceq_heel1415(in1,toe_th,dmax,cmax,k,us,ud)
%HESS_GRF_CEQ_HEEL1415
% OUT1 = HESS_GRF_CEQ_HEEL1415(IN1,TOE_TH,DMAX,CMAX,K,US,UD)
% This function was generated by the Symbolic Math Toolbox version 8.4.
% 23-Jun-2020 09:33:44
out1 = 0.0;
|
function Keiba()
clear
clc
[Number_0, Name_0, Jockie_0, Weight_0, Popularity_0, Odds_0] = ImportRaceInfo('G1Arimakinen_2015.csv');
disp('[出走馬]');
for i = 1:size(Number_0, 1)
fprintf('%d, %s\n', Number_0(i), char(Name_0(i)));
end
disp('[順位予想]');
disp('1.直近5走順位');
disp('2.直近10走順位');
disp('3.直近5走順位(グレード考慮)');
disp(... |
function [ S ] = momentoinvariante( E,m,n,c )
% Si c es 0 cuenta el negro sino los blancos.
[x,y]=size(E);
S=0;
M00=momento(E,0,0,c);
M10=momento(E,1,0,c);
M01=momento(E,0,1,c);
cx=M10/M00;
cy=M01/M00;
for i=1:x
for j=1:y
if (c==0)
S=(abs(i-cx))^m*(abs(j-cy))^n*(255-E(i,j))/255+S;
else
... |
function plot()
ddir='/rota/Analysis/PS/osc2011/RadDamp/20120926_e500_p102.trace';
dstr='20120926';
file='a1_827400.0Hz0.8V5000cyc_43322.65628s_2643.07mA_50mV_li10mV_1.02rad_0.00mHz_e500.0mA_sig.osc.gz';
load([ddir '/trace_data/' dstr '_' file '.mat']);
plot(time,amp);
fo=fopen('data1.txt', 'w');
for k=... |
function [VolMat]=generateSumMatrixFromVector(Vol)
%Finds total volume of each parcel
%
sz=length(Vol);
VolMat=zeros(sz,sz);
for i=1:sz
cn1=Vol(i);
for j=1:sz
cn2=Vol(j);
VolMat(i,j)=cn1+cn2;
end
end
|
function result = QueryImageTest(fileName, dict_words, dict, inv_file, if_weight, if_norm, if_dist, verbose, files, top)
inv = inv_file{1};
I = im2single(rgb2gray(imread(fileName)));
% compute SIFT features
[frame, sift] = vl_covdet(I,'Method', 'HarrisLaplace', 'estimateAffineShape', true);
% Co... |
% Flexible CG method
% Compute preconditioner A -> M
% Initialize x, p, r = b - A * x, r_old, tau = r' * r, gamma_old
while(tau > tau_max)
z = M \ r; % = M^{-1} r, apply preconditioner
gamma_new = r' * z; % DOT product
t = r - r_old; % AXPY-type... |
function feats = relieffWrapper(X,Y,varargin)
[feats wts]= relieff(X,Y,varargin{3},varargin{4:end});
end |
clc
clear
RGB = imread('img_g_5.png');
LEN = 31;
THETA = 11;
PSF = fspecial('motion',LEN,THETA); % create PSF
Blurred = imfilter(RGB,PSF,'circular','conv');
imshow(Blurred);
title('Blurred Image');
|
%% Input
% time - ultimo istante [double]
% value - valore rilevati nell'ultimo istante [double[]]
% pol - coefficienti grado [double[]]
% S - vettore precisione ... |
function [duvidp_uvip] = Compute_duvidp_uvip(obj,~)
%Compute_duvidp_uip Summary of this function goes here
% Detailed explanation goes here
duvidp_uvip = Compute_duvidp_uvip@iConcat(obj);
duvidp_uvip = obj.ComputeComplexDerivative(duvidp_uvip);
end
|
function [Y1,Y2,Y3,Y4,X5]=py4enc(imageinput,h)
% py4enc converts an image input into high pass images and a tiny lowpass
% image.
%
% [Y0,Y1,Y2,Y3,X4]=py4enc(imageinput,h)
% Where h is the filter
% and Y0 - Y4 are the high pass images, and X4 is the tiny lowpass image.
X{1}=imageinput;
for i=1:4
inter=rowdec(X... |
function [out] = main_seed_ne(input)
[~, ~, seed] = xlsread('seed_82615.xlsx','russell_min');
seed = seed(2:end,end);
seed(cellfun(@(x) ~isempty(x) && isnumeric(x) && isnan(x),seed)) = {''};
[~,~,s]=intersect(seed,{input.compounds.cid});
x0 = zeros(length(input.compounds),1);
x0(s) = 1;
out = netExp(input.R,inpu... |
function X = uq_gamma_invcdf( F, parameters )
% UQ_GAMMA_INVCDF(F, parameters) calculates the inverse Cumulative Density Function
% values of CDF values F of samples X that follow a Gamma distribution with
% parameters specified in the vector 'parameters'
%
% Input parameters:
%
% 'X' The samples
%
% ... |
function [MAP_states] = Viterbi(State_space, Initial_probabilities, Observation, Transition_matrix, Emission_matrix)
% General Viterbi algorithm
% output MAP_states is the most probable sequence of hidden states for
% a given Observation sequence.
% Let observation space be {x_1,...,x_m}.
% Arguments:
% State_space: ve... |
function [valor_original,valor_predicho] = draw_ressults(cierre,predicciones,horizonte,relativo)
%DRAW_RESSULTS Summary of this function goes here
% Detailed explanation goes here
[m,n] = size(cierre);
if relativo == 1
for i=1:m-horizonte
valor_original(i) = cierre(i + ... |
classdef kmeans
methods (Static)
function [y_pred, C, ss, it] = train(X, k, C, maxIt)
n = size(X, 1);
d = size(X, 2);
y_pred = zeros(n, 1);
for it = 1 : maxIt
% Calculating Eucledian Dist... |
% Assignment 7 ; Problem 1
% dx/dt = W/V-x(Q/V) ; V = 10^6 , W = 10^6 , Q = 10^5;
% dx/dt = a-bx
t0 = 0;
x0 = 0; % Initial conditions
tEnd = 10;
h = 0.05;
N = (tEnd-t0)/h;
% V = 10^6; W = 10^6; Q = 10^5;
% a = W/V; b = Q/V;
%% Initializing Solutions
T = [t0:h:tEnd]';
X = zeros(N + 1,1);
X(1) = x0;
%% Solving using Eul... |
function ComparePickup(U,cb,h)
%比较Fernandez Luque,Van Rijn和Wu (2008)公式, E是按体积记的
d=790e-6;
rou_s=2650;
T=30;
pFL=0.0854;
pWu=0.0000262;
c_drag=0.01;
delta=(rou_s-1000)/1000;
niu=GetKvisc(T);
dstar=d*(delta*9.81/niu/niu)^(1/3);
theta_cr=Crit_Shields( d, rou_s, T );
if nargin==0
nx=60;
thetas=linspace(0.4,1,nx)... |
function [BEST_AP, BEST_LAMBDA] = lr_selectParam2(classes,...
Xtrain, ytrain, Xval, yval)
%% init
% clear ; close all; clc;
globals();
%% ============= Part 2: Regularization and Accuracies =============
fprintf('start selecting best params...\n');
LAMBDAS = [0.01 0.03 0.1 0.3 1.0 3.0 10 30];
BEST_AP = 0;
BEST_LA... |
function wML = calcGaussML_ARD(X, Y, rho)
ssq = rho(end);
rho = rho(1:end-1);
d = size(X,2);
assert(numel(rho) == d);
RegInv = ml.ridgeInvPrior(diag(rho), d);
wML = tools.meanInvCov(X'*X, X'*Y, RegInv, ssq);
% wML(rho < 1e-3) = 0;
end
|
%% script to plot slip history stairs from a .out file
%
% Requires sliphistory.out/slips file
% User must input the site specific details for the SL code in the section
% below
%
%
% LCG Nov 2018
clear
close all
%% Set up for plotting fit to data
faultname = 'Caprociano';
slip_file = '../sliphistory... |
% clear screen and variables
clc
clearvars
% enter cpp source file for Particle Filter based likelihood estimation
Cpp_Source = './ParticleFilter.cpp';
Cpp_Binary = './ParticleFilter.o';
% enter input and output files
Tree_input = './ExampleTrees/Tree4.txt'; % this is the file from which the tree will be read
Output... |
function matTimeStepping343(obj)
[EXa, IMa, EXb, IMb, c] = GetRKParamter();
time = obj.getOption('startTime');
ftime = obj.getOption('finalTime');
fphys = obj.fphys;
%> allocate space for the rhs to be stored
ExplicitRHS1d = zeros(obj.meshUnion(1).cell.Np, obj.meshUnion(1).K, 4*obj.Nvar);
ImplicitRHS1d = zeros(obj.mesh... |
function connectivity = compute_connectivity(mesh)
N = length(mesh(:,1));
connectivity = zeros(N,4);
% For each cell face, determine neighboring cells
for iCell = 1:N
tempmesh = mesh;
tempmesh(iCell,:) = 0;
for iFace = 1:4
id1 = mesh(iCell,iFace);
... |
#include "lib/std.mi"
Function refreshVisSettings();
Function setVis (int mode);
Function ProcessMenuResult (int a);
Function setColorBands (String rgb, int start, int end); //set bands color in range (1-16) rgb value("0,255,127"), start position(4), end position(12)
Function setColorBandsOdd (String rgb);... |
%get_features
function f = get_features(cluster)
[e1, e2] = klt(cluster.points(:,1), cluster.points(:,2));
[c] = mean(cluster.points);
[maxs] = max(cluster.points);
[mins] = min(cluster.points);
e2_p = sum(e2/sum(sum(e2)));
if (e2_p(2) > 0.99)
n_axes = 1;
else
n_axes = 2;
end
% n_axes, x_m, y_m, x_min, y... |
% Engin Tola
% etola@yahoo.com
function out = AxisAngle_2_Quaternion(inp);
out = [ inp(1)*sin(inp(4)/2) inp(2)*sin(inp(4)/2) inp(3)*sin(inp(4)/2) cos(inp(4)/2) ];
|
clear
global finalMatrix
%global params
load UtanVeckaUtanVikt
finalMatrix = finalMatrix(1:50000,:);
num_threads = 1;
data_points = length(finalMatrix);
w = ones(data_points,1);
high_strike = max(finalMatrix(:,1));
for i = 1:data_points
w(i) = (high_strike - finalMatrix(i,1)).^4 /(length(finalMatrix)*10^17);
end
re... |
function [glmtrial, unitOfTime, binSize, nTrials, binfun, numMD, numPFC, RejMD, RejPFC, keptPFC, keptMD, CMIPFC, CMIMD, Z] = packageData_for_glm(dataName)
if ~ismac
dataRep = 'C:\Users\Halassalab-CG\Dropbox\Rajeev\ForContextSwitchProject\DoubleCueDatabase\BPM1_3\UniLatMDHalo-Low\';
elseif ismac
% da... |
function [PP_CFG, PP_DATA] = RTM_postprocessing_multi(PP_CFG, PP_DATA, CFG, DATA, test_idx)
[PP_CFG, PP_DATA] = RT_postprocessing_core_multi(PP_CFG, PP_DATA, CFG, DATA, test_idx); |
%% ================================================================
% demo_cs.m
% This program is used to demonstrate how to use CS_NLTV (compress sensing with NLTV) code
% This demo sets up a subsampled Fourier matrix, A=RF, where R is a diagonal matrix with entries randomly chosen
% to be 1 or 0, and F i... |
function m = SimVarD_Rotor(nameWithoutExtension, ObstacleX, ObstacleY, ObstacleRadius, ObstacleTime, PacemakerX, PacemakerY, NumberOfBeats);
%% #1 - COMPILE, SET PARAMETERS FOR SIMULATION
cd('/home/vincent/Documents/Glass-Bub-Lab/Simulations/');
mex ../px_ch_VarD_Rotor.cpp
%%
% nameWithoutExtension = 'Sim_01-Mar-20... |
function [ Q ] = S2Q( S )
% transform S to Q
% S: [rho u p]
% Q: [rho rho*u rho*E]
global gamma;
rho=S(:,1);
u=S(:,2);
p=S(:,3);
Q=[rho,rho.*u,p/(gamma-1)+0.5*rho.*u.^2];
end
|
function [img_buf,bbox_buf] = img_to_sample1(img,bbox,f_list,dis)
cx = round(bbox(1)+bbox(3)/2);
cy = round(bbox(2)+bbox(4)/2);
longer = max(bbox(3),bbox(4));
img_buf = {};
bbox_buf = [];
for f = f_list
side = round(longer*f);
off_x = round( (side-bbo... |
function f = rolloverFutures(frontPrices, backPrices, tickers)
% Computes the returns on the front-month futures contracts rolling over
% on the day preceding expiration. Each row represents a trading day, and
% each column an asset.
% The return matrix will be of the same size as the incoming price matrices
% with ... |
clear;clc
result=ML_func9_4('linear') |
disp('MÉTODO DE LAS DIFERENCIAS DIVIDIDAS')
val=input('Valor a interpolar x: ');
dato=M(1:end,2);
p=M(1:end,3);
t=length(dato);
DD=zeros(t);
disp('Obteniendo las diferencias divididas:');
DD(:,1)=p';
for j=2:t
fprintf('Columna %2.0f de diferencias divididas\n',j);
for i=j:t
DD(i,j)=(DD(i,j-1)-DD(i-1,j-1... |
function [k] = quadratic_kernel(x_n, x_m, hyper)
%QUADRATIC_KERNEL Exponential of the quadratice form
% Kernel widely used in for Gaussian process regression
theta0 = hyper(1);
theta1 = hyper(2);
theta2 = hyper(3);
theta3 = hyper(4);
k = theta0*exp(-theta1/2 * norm(x_n-x_m)^2) + theta2 + thet... |
function crlb = cramerRaoLowerBoundEnergyIntegratingDetector( spectrum, Ttissue, Tbone, Tmetal )
energyBinLabels = spectrum.energyBinLabels;
photonsPerEnergyBin = spectrum.photonsPerEnergyBin;
photonsPerEnergyBin = photonsPerEnergyBin * 1e4 / sum( photonsPerEnergyBin );
photonsPerEnergyBin = hDetectorEnergyResponse... |
clear all,
close all
clc
%=========Parameters ==============
gamma=0.1;
x = 10:10:1000; %Length sliding windows
error_f = zeros(length(x),1);
i=1;
nt=100;
%======Format data================
importfile('data_2000.csv');
index = 46; %indice del activo a predecir
%data = data(1:200,1:10);
[N... |
%% Speed tests
% Scorbot encoder ratios
ENC2RAD = 2.0*pi/(3.0*160.0*96.0);
RAD2ENC = 1.0/(2.0*pi/(3.0*160.0*96.0));
Ts = 1e-3;
Thf = 1e-6;
Nr = 96;
% Speed arrays
speed_rad = diff(pos)/Ts;
speed_rps = speed_rad/(2*pi);
speed_rpm = speed_rps*60;
plot(time(2:end),speed_rad,'r');
legend('Velocidad angular');
xlabel('Tiemp... |
function out = dataShuff(indata,divisions)
% Function to shuffle data (time series) by number of divisions
%
% Usage
% out = dataShuff(indata,divisions)
%
%
lData = length(indata);
lDiv = lData./divisions;
newData = ones(1,lData);
seq = randperm(divisions);
for x = 1:divisions
oldData = indata(lDiv*(x... |
function add_processed_behavior(varargin)
% ADD_PROCESSED_BEHAVIOR -- Add processed behavior measures to the .h5
% database file.
%
% IN:
% - `varargin` ('name', value) -- Optionally pass in a config file
% with 'config', conf
io = dsp2.io.get_dsp_h5();
db = dsp2.database.get_sqlite_db();
def... |
function [error] = pid_zwykly(argK, argTi, argTd, draw)
%OPTYMALNE WEDŁUG FMINCON: K = 0.3004, Ti = 6.9992, Td = 2.0577
close all
K = argK;
Ti = argTi;
Td = argTd;
error = 0;
start = 7;
N = 1200;
Tp = 0.5;
Upp = 0;
Ypp = 0;
u = Upp*ones(N, 1);
y = Ypp*ones(N, 1);
Umin = -1;
Umax = 1;
prevE = 0;
prevUi = 0;
yzad(... |
% Codigo para imprimir un rectangulo
fprintf('\nrectangulo\n\n')
for k=1:7
for l=1:6
fprintf('*')
end;
fprintf('\n')
end |
function [site, neuronEnsNum, pokein, pokeout, beh_ens] = load_spc(filename)
load(filename)
names1 = whos ('spikeOFC*');
for ii = 1:length(names1)
if ii ==1
site = [eval(names1(ii).name)];
neuronsPerSite(ii,1) = 1;
neuronsPerSite(ii,2) = size(site,1);
else
ne... |
% Simulation of massive Kuramoto model/HMF model
tic
clear all ;close all; clc;
N=100; %No of coupled pendulum
T=1000;% Total time
tau=0.01;% Timestep
combination=1;
%% Defining the coupling constant K
K=1;
%Creating vector for theta and thetadot
thetadot=zeros(N,1);
theta=zeros(N,1);
en=zeros(N,1);
phi=zeros(N,1... |
function [xRot,xPCAwhite,xZCAwhite]=ZCA(x)
epsilon=0.01;
x=double(x);
avg=mean(x(:));
x=x-avg;
sigma=x*x'/size(x,2);
[U,S,V] = svd(sigma);
xRot=U'*x;
xPCAwhite = diag(1./sqrt(diag(S) + epsilon)) * U' * x;
xZCAwhite = U * diag(1./sqrt(diag(S) + epsilon)) * U' * x;
|
function [epsilon,alpha]=LearnD2d(Lam,d,Ydata,D2de1,D2de3,D2da);
for x = 1:length(Lam)
[epsilon(1,x),acc,decV] = svmpredict(.2,Ydata(x,:),D2de1, ['libsvm_options']);
[epsilon(2,x),acc,decV] = svmpredict(.2,Ydata(x,:),D2de3, ['libsvm_options']);
[alpha(x),acc,decV] = svmpredict(.2,Ydata(x,:),D2da, ['libsvm_... |
function varargout=KK_Cluster(varargin)
if nargin>=1&&~isempty(varargin{1})
features=varargin{1};
else
error('KK_Cluster requires at least one input argument')
end
nSpikes=size(features,1);
nFeatures=size(features,2);
if nargin>=2&&~isempty(varargin{2})
feature_selection=varargin{2};
else
... |
% EJERCICIOS RESUELTOS DE VISIÓN POR COMPUTADOR
% Autores: Gonzalo Pajares y Jesús Manuel de la Cruz
% Copyright RA-MA, 2007
% Ejercicio 5.13: Suavizado y Realzado: expansión de histograma
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 5.11.4 Histogramas: modificación
%%%%%%%%%%%%... |
function dobj = MixDualLoss(y,X,Zc,a, Tau)
[N,D] = size(X);
Wtmp = Zc'* spdiags(a,0,N,N) *X; %K by D
dobj = -norm(Wtmp,'fro')^2/(2*Tau) + y'*a - norm(a)^2/2;
|
% Computer Vision Assignment 4 - Optical Flow
% Bas Buller & Rick Feith
close all; clear all; clc;
%% Initialize parameters
sphere1 = 'sphere1.ppm';
sphere2 = 'sphere2.ppm';
synth1 = 'synth1.pgm';
synth2 = 'synth2.pgm';
sigma = 1; % Sigma value for the derivati... |
function DCM = angle_to_dcm( alpha )
%ANGLE_TO_DCM return dcm based on inputed angles
%
% DESCRIPTION : calculate dcm based on euler angles given in vector
% alpha. The transformation sequence is as follows: 1. X, 2. Y, 3. Z.
% INPUTS:
% - alpha : 1x3, matrice, euler angles [rad]
Q_x = [ 1, ... |
function Plot_All_Ave_dFF_by_stim(~,~, cmin, cmax)
%%%%%%%%%%
% Show Matrix for averaged traces for all ROI
%%%%%%%%%
global imgobj
global sobj
%%%%%%%%%%
mag_os = 200; %oversampling x200
c_min = str2double(get(cmin, 'string'));
c_max = str2double(get(cmax, 'string'));
%% Get_dFF, Averaged by Stim Types
%[ ~, datap, ... |
function [ t ] = get_centers( K,D,i_coord,offset_i_coord,lb,ub )
% gets N centers of dimensions D where we specify which coordinate (i_coord)
% is where the wedge is located at with offset_i_coord
%t = lb + (ub - lb).*rand(K,D);
%t = lb + (ub - lb).*rand(K,D);
t = zeros(K,D);
t(:,1) = linspace(lb,ub,K)';
t(:,i_coord) =... |
function ts = ArrayGener(M_X,M_U,tau,lmax,uconstr,system)
% modified based on ArrayGener_ts
% add input constraints
% version for input constraints
% for push-recovery case 4
% input 'uconstr' is a structure having all information used for function
% uconstraints()
%% initialization
g = system.g;
h0 = system.h0;
% i... |
% FUNCTION THAT RUNS MY THREE SIMULATIONS OF THE MONTY HALL PROBLEM USING
% 1,000, 10,000, AND 100,000 SIMULATIONS RESPECTIVELY AND GIVES RESULTS AS
% A STRING
function results = MontyHallProblem()
% INITIALIZE VARIABLES THAT WILL BE USED IN STATISTICAL ANALYSIS
numRealizationsMin = 1000;
numReali... |
function r = jessExec(cmd)
eval(['r.eval(' cmd ');']);
|
function [Pxx,Mxx,Sxx,Xs,Yi,Zi]=ay_filter(method,Param,Yc,Zc,T)
% This function predict
% Input:
% 1. Method, 1 means deletion, 2 means imputation, 3 means full likelihood, and 4 is Gaussian apprximation
% 2. Param, it containts model parameters (Check Manual for the Param description)
% 3. Yc, is ... |
%test
a = -2;
b = 4;
T = 6.28;
dt = 0.1;
dx = 0.1;
c = @(t,x) sin(t);
f = @(x) exp(-x.^2);
u = @(t,x) exp(-(x-(1-cos(t))).^2);
g = @(t) u(t,a);
h = @(t) u(t,b);
x = [a:dx:b];
y = [0:dt:T];
[X,Y] = meshgrid(x,y);
U = resiPoVetru(c,f,g,h,T,a,b,dt,dx);
surf(X,Y,U)
V = u(Y,X);
max(max(abs(V-U))) |
len_name = length(cost_function_names);
len_ran = length(param.cost_functions_ioc);
len_svd = length([output_inverse{ind_windowCount}(1).svd_s]);
len_rmse = length(currRMSE_set(1).arrayName);
len_lambda = size(lambda_array, 1);
len_Jbreakdown = length(direct_check_flags{1}.J_breakdown.report);
len_residual = length(out... |
function u = svt(x,tt);
% soft thresholding
u = max(1-tt./abs(x),0).*x;
|
numData = 5000 ;
dimension = 2 ;
data = rand(dimension,numData) ;
numClusters = 30 ;
[centers, assignments] = vl_kmeans(data, numClusters);
x = rand(dimension, 2) ;
[~, k] = min(vl_alldist(x, centers));
|
function K = findRowsOfAInB(A,B)
% K are indices into rows of B. If row i of A cannot be found in B,
% K(i) is NaN;
%
% @ Matt Golub, 2018.
N = size(A,1);
K = nan(N,1);
for n = 1:N
idx = find(all(bsxfun(@eq,A(n,:),B),2),1,'first');
if ~isempty(idx)
K(n) = idx;
end
end
end |
function [hyperparameters] = empiricalhyperparameters(x,z,c,p,q,gprior)
%empiricalhyperparameters: defines empirical hyperparameters based on the
%data
% INPUTs:
% x: covariate matrix of size nx(p+q)
% z: observed response of size nxd
% c: censoring indicators of size nxb - for age at event variables
% gprior:... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.