text stringlengths 8 6.12M |
|---|
function [h1, h2, h12] = umts_duc_filter_conf2(Quantize, Nfft, ShowPlots)
if (nargin<3)
ShowPlots = 0;
end
if (nargin<2)
Nfft = 32768;
end
Fs = 3.84;
% First Interpolation Filter - RRC
Hd = srrc;
h1 = Hd.Numerator;
H1 = 20*log10(eps + abs(fftshift(fft(h1, Nfft))));
if Quantize
h1 = xquantize(h1, 18, 1)/... |
%%
clear;
filename = '/home/sheel/Work2/projects_data/spod_re5e4/frinf/force_files/forces_xyz_imb0001_t913_t1374.plt';
A = importdata(filename);
time = A(:,1);
time_final(1,1) = time(1,1);
count = 1;
for i = 2:size(time,1)-1
t1 = time_final(count,1);
t2 = time(i+1,1);
if t2 > t1
count = count +... |
function b = determine_b
% determine_b = Determine the base of the floating point number system on
% this computer
format long
% first phase
a = 1;
while ((a+1) -a) == 1,
a = a*2
end
a+1
a
(a+1)-a
% second phase
i = 1;
while (a == (a+i)),
i = i + 1
end
% result
a+i
a
b = (a + i) - a; |
% FR = 49:50:2279;
FR = 300:250:18093;
DATA_old = DATA;
clear DATA;
DATA = cell(length(FR), 1);
for i = 1:length(FR)
DATA{i} = DATA_old{FR(i)} ;
end
|
close all;
clear;
%% Visualizar los datos y extraer subconjunto binario
datos_caso=readtable('Frogs_MFCCs.csv');
datos_MFCCs=datos_caso(:,1:22);
X=table2array(datos_MFCCs);
%%
Y=double(categorical(datos_caso.Genus));
idx= Y==3 | Y==5; % me quedo con los valores correspondientes que serian los dos tipos de ge... |
function varargout = uq_PCE_eval(current_model,X)
% Y = UQ_PCE_EVAL(CURRENT_MODEL,X): evaluates the response of the PCE
% metamodel CURRENT_MODEL onto the vector of inputs X
%
% See also: UQ_EVAL_UQ_METAMODEL,UQ_KRIGING_EVAL,UQ_PCE_EVAL_UNIPOLY,UQ_PCE_CREATE_PSI
%% Command line check
% do nothing if X is empty and... |
clear; clc; close all;
[x,fs] = audioread('_a_ao.wav');
x = x(46321:52850);
x_len = size(x,1);
a = [0:0.001:1]';
a = 1-a.^2;
b = flipud(a);
lap = x(x_len-1000:x_len).*b +x(1:1001).*a;
mid = x(1002:x_len-1001);
result = [lap;mid;lap;mid];
result = [result;result];
result = [result;result];
hold on;
% plot(lap);
%plot(x... |
classdef MvnDist < MultivarDist
% Multivariate Normal Distribution
properties
dof;
ndimensions;
params;
prior;
infEng;
fitEng;
end
properties
covType;
end
methods
function model = MvnDist(varargin)
if nargin == 0; return ;end
[ model.param... |
function freq_data = get_freq(EEG, opt)
% get_freq(db, r, opt)
% db - eegDb database
% r - database entry to freq-torture
%
% opt:
% freq - frequencies to compute
% chan - channels to get freq from
% winlen - window length for each freq bin
% timestep - time step of the fft window
% defaults:
ensure_opt
% turn data... |
function [SalMap] = GetCA(imgName)
MOV = saliency({imgName});
SalMap = MOV{1}.SaliencyMap;
img = imread(imgName);
height=size(img,1);
width=size(img,2);
SalMap = imresize(SalMap, [height, width]);
end
|
% inas.m
% NaP Sodium channel
%
% modeled after Mahon2000
% using m formulation
% returns also steady-state values
%
% $Revision:$
%
function [I_NaS, dm, m_inf] = inas(V_m, m)
E_NaS = 40; % mV
g_NaS = 0.11; % mS/cm^2
I_NaS = g_NaS*m*(V_m - E_NaS);
m_inf = mylog(V_m, 1, -16.0, -9.4);
tau_m = myact(V_m, 637.8, ... |
function[q] = Inverse_kinematics_POE(q0,Td)
%此程序是逆运动学数值求解,采用的方法是基于物体雅可比矩阵的牛顿-拉夫森法
%初始化:已知目标矩阵Td,初始角度估计值q0,设定i=0
%如果初始估计值与真实值没有足够接近,则迭代过程可能不收敛
%解出来的角度与初始角度有关
theta = q0;
for i = 1:1000
disp(i)
T_sb = Forward_kinematics_POE(theta);
T_bd = inv(T_sb)*Td; %以e为底
Vb_frame = logm(T_bd); %T_bd的矩阵对数
v ... |
% Input vectors should be column vectors of dimension Nx1
% Both vectors should have the same dimension
function [confusionMatrix] = createConfusionMatrix(confusionMatrix, actual, predictions)
for i = 1 : length(actual)
currentValue = confusionMatrix(actual(i, :), predictions(i, :));
confusionMatrix... |
function [CL, TAU1, TAU2] = sym_jc_tvp_CL(theta,Z,thetabar)
% function [CL, TAU1, TAU2] = sym_jc_tvp_CL(theta,Z,thetabar)
%
% The negative copula log-likelihood of the symmetrised Joe-Clayton copula
% with time-varying tail dependence
%
% Wed, 10 May, 2003.
%
% Andrew Patton
%
% INPUTS: theta = [kappa,gamma]... |
function [mTR, sdTR, nTR, mPR, sdPR, nPR] = getML_MTRate(monk, recompute)
% DESCRIPTION:
% Get average rate for MT neurons for each stimulus conditions.
% There are in total 13 stimulus conditions: 6 for each coh at the pref dir,
% 6 for each coh at the null dir, and 0% coh for both dir.
%
% OUTPUT:
% Each of the f... |
clear all
close all
clc
%% Test GSM_Real_Concat
disp('- GSM_Real_Concat test');
% specify database
bin_root = ['..' ...
filesep 'binarydb' ...
filesep];
name = 'lfpw';
type = 'train';
ann = 'our';
db = DB([name '-' type '-' ann],bin_root);
% number of image
n_data = 100;
% get dataset
id... |
% if v(i,1) <= 15
Bv(i,1) = max_brake;
% end
% if v(i,1) > 15
% Bv(i,1) = max_brake - (1000*(v(i,1)-15));
% end |
function MSRCP = MSRCP(image,sigmas,s1,s2)
%MSRCP offers an implementation of the MSRCR which is applied to the three
%intensity channels with chromacity preservation
% ARGUMENTS:
% image: image to be modified
% sigmas: scales
% s1: percentage of clipping pixels for low values
% s2: percentage of clipping... |
function [ m ] = discretiseMatrix(m, varargin )
%DISCRETISEMATRIX discretises a matrix
% Required parameter: data
% Optional parameters: min, max, bins
% Ouput: Vector with values in [1, bins]
p = inputParser;
p.addOptional('min', 0, @isscalar);
p.addOptional('max', 0, @isscalar);
p.addOptional('bins', 30, ... |
function [cortex,electrodes,aligment_pos] = loadToStandard(pathToSubject,pathToAlignmentPoints,Norig,Torig,pathToElectrodes,alignment)
%LOADTOSTANDARD Summary of this function goes here
% Detailed explanation goes here
if(nargin < 6)
alignment='tal';
end
pathToLhPial = strcat(pathToSubject, '/surf/lh.pial');
pa... |
clear all;
global saveGifs
saveGifs = true;
global filename;
sigma_u = 0.05*eye(3);
timesteps = 50;
%%%%%%%%%%%%%%%%%%
%% Lake Calhoun
%%%%%%%%%%%%%%%%%%
%% Lake calhuoun, straight motion, unknown initial position.
close all;
filename = 'calhoun_straight_unknown';
mcl_simulation('calhoun', 'straight', false, 5000... |
disp("Test passed!")
|
function check_greater_than_0(value)
testCase = matlab.unittest.TestCase.forInteractiveUse;
verifyGreaterThan(testCase, value, 0);
end
|
function varargout = anganova(ang, varargin)
% ANGANOVA - Anova-type test on circular data
%
% P = anganova(ang, method, group)
%
% One way "ANOVA" type test on circular data.
% Available methods:
% 'watson-williams','ww': Parametric test for equality of means
% 'likelihood ratio','likelihood','lr': Parametr... |
function [accuracyTraining, accuracyTest, cmTraining , cmTest] = main(file_path)
[realRes, datArr] = getProcessedData(2,file_path);
a = learningParameter(datArr,realRes);
bgMatrix = zeros(2,1);
bgMatrix(1,1) = backgroundProbability(realRes , 'student');
bgMatrix(2,1) = backgroundProbability(realRes , 'facult... |
function [ mfamodel ] = defopt( mfamodel )
% DEFOPT creates a default options set for MFA simulations
opt = struct('ss',false,'sim_na',true,'fcor',false,'default_sd',false,'output_display',true,'dfbase',1e-6,'conf_lvl',0.95,'multistart',1,'reinit',true);
opt.simsens = true; %simulate sensitivities
opt.conf_set = 'm... |
% clear all;
clear all;
close all;
load('/Users/yueweiyang/Documents/study/duke/independent study/fall 2017/matlab/multiple instance learning/result/data/Spiralssize30000nclusters2noise0.00.mat')
%
%
% pos = [1:3000];
% neg = [3001:6000];
%
% pos = pos(randperm(3000));
% neg = neg(randperm(3000));
%
% train = [pos... |
function randMat = ctrl_getRandomMatrix(size)
%In general, you can generate N random numbers in the interval
%[a,b] with the formula r = a + (b-a).*rand(N,1).
rows=size(1);
N=size(2);
random_column
a=1;
while a <= rows
r = a + (b-a).*rand(N,1)
a=a+1;
end
end |
clf
% ------rectangular wave------
ele_nums = 1024
mid = ceil(ele_nums/2)
half = 5
% rectangular pulse
x = zeros(1, ele_nums)
x(mid-half : mid+half) = 1
subplot(3,1,1);stem(abs(fft(rect)),'.-');title('rectangular wave freq response');grid on;
% ------filter the wave------
% -----2-2BP----
X_C = [1, -1.6, -0.16]
Y_C ... |
ai = [2 4 8 10];
k = 10;
[A, B, C] = ode2phv(ai, k)
|
function visual_pathway_third_version()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Digtal Human Visual Cortex Pathway %
% Re... |
function [cycle_index,amps] = plot_cycle_fit(Data,event_index,amps,poi,fit_model,S_period,type)
% This function is used to plot the fitted traces of all cycles overlaying
% together
% Time per cycle (how many data points in one cycle, not in seconds)
t_per_cycle = round(2*pi/fit_model.b1);
% Cyc... |
% 7/26/13
% calculateInputs.m
% finds inputs to 2d quadrotor
% Dependancies: desiredTraj.m
%
% inputs:
% t: real value, current time
% x2: nx1 vector, current state
% g, mQ, JQ: real values, constants
% kp, kd, kp_phi, kd_phi: real values, gains
% outputs:
% [f M]: 1x2 vector, control inputs for 2d quadrotor... |
function setup_optimizer
fprintf('Setting up optimizer ... ');
if ismac
addpath('/Library/gurobi900/mac64/matlab');
fprintf('Loading Gurobi on MacOS ... ');
elseif ispc
addpath('C:\gurobi810\win64\matlab');
fprintf('Loading Gurobi on Windows ... ');
else
error('Configure Gurobi for Linux');
end
f... |
function MPIparams = adjustFOV(MPIparams)
zSpeed = 1/(MPIparams.Gzz*(1/MPIparams.Rs(3))); % speed in z-axis
zPeriods = floor(MPIparams.FOV_z*MPIparams.f_drive/zSpeed); % integer number of periods in the whole fov (this changes the FOV_z distance slightly)
zPeriods = zPeriods-mod(zPeriods, MPIparams.num... |
classdef (Abstract) Problem < handle
%PROBLEM Summary of this class goes here
% Detailed explanation goes here
properties(Constant)
Valid = 1;
NonFinite = -65536;
InternalError = -65537;
end
properties(SetAccess=protected)
name;
description;
inputDescription = {};
inputType = {};
parameterCoun... |
function [] = example_minFunc_tune(objType)
nTrials = inf;
plotIter = 5;
%% Objective Function type and problem size
nInstances = 500;
nVars = 100;
nClasses = 5;
%% Global options
gOptions = [];
gOptions.maxFunEvals = 250;
gOptions.Display = 'Full';
gOptions.TolX = 1e-10;
gOptions.TolFun = 1e-10;
gOp... |
clc;clear;close all;
format = {'*.txt','TXT(*.txt)';'*.*','All Files(*.*)'};
[fileName, filePath] = uigetfile(format,'导入外部数据','*.txt','MultiSelect','on');
if ~isequal([fileName, filePath],[0, 0]);
fileFullName = strcat(filePath, fileName);
else
return;
end
if iscell(fileFullName)
N = length(fileFullName); ... |
classdef(Enumeration) AlgType < int8
enumeration
No(-1)
Yes(1)
Both(0)
CP(1)
Tucker(2)
PMF(3)
BCD(4)
end
end |
root = '/home/sharpwaveripple/phd/apathy/networks/';
BNV_path = '~/matlab/toolbox/BrainNetViewer/';
config_file = strcat(root, 'results/Cfg.mat');
surf_file = strcat(BNV_path, 'Data/SurfTemplate/BrainMesh_ICBM152.nv');
node_file = strcat(root, 'results/node.node');
adj_file = strcat(root, 'results/adj.edge');
cd(BNV_p... |
clear; clc
%% without hilbert fractal
C = imread('Lena.png');
H = imread('mandril.png');
c = C(1:size(H,1),1:size(H,2),:);
s = bitshift( bitshift(c,-4),4) + bitshift(H,-4);
S = C;
S(1:size(H,1),1:size(H,2),:) = s;
figure;
subplot(231);imshow(S)
subplot(232); imshow( bitshift(S,4));
subplot(233);ims... |
function [ centers ] = sskppInit( data, k, knownLabels, trueLabels )
%Chooses the centers according to D^2 weighting while taking supervised
%labels into account
%############### INPUTS ###############
%data: n x d data matrix
%k: the number of groups
%knownLabels: subset of 1:n indicating indices of data with labels
%... |
function [IM, back, front]=bgcleanup( IM, debug, addframe, slow_clean )
[IM, back, front]=bgremove( IM, debug, addframe, slow_clean );
end
|
clear all
close all
clc
%% Test FD_MAT
disp('- FD_Mat test');
% specify database
bin_root = ['..' ...
filesep 'binarydb' ...
filesep];
name = 'lfpw';
type = 'train';
ann = 'our';
db = DB([name '-' type '-' ann],bin_root);
% number of image
n_data = 1;
% get dataset
id = 1:n_data;
reg_ex... |
function point_num = xyz_header_read ( input_filename )
%*****************************************************************************80
%
%% XYZ_HEADER_READ determines the number of points in an XYZ file.
%
% Discussion:
%
% This routine assumes that the file contains exactly three kinds of
% records:
%
% C... |
%programServo_LinSamples_FixedGain Example file that shows how to use the SERVO and SERVOCMD
%methods to program a particular sequence into the servo controller.
%
% This file demonstrates how to use linear ramps with fixed gains.
%
% To test this file out, you should connect the output of the DAC
% evaluation bo... |
purge
x = 100; %I start with 10 apples
N = 100;
xactual = zeros(N,1);
xaverage = zeros(N,1);
xsum_vec = zeros(N,1);
xsum = x;
for ii = 1:N
xactual(ii) = x;
xsum_vec(ii) = xsum;
xaverage(ii) = xsum/ii;
%x = x + (-1)^(ii+1); %%S1
x = x + (-1)^(ii+1)*ii;
xsum = xsum + x;
end
... |
clc
clear
close
M=16;
N=600;
N1 = N/10; % 10 is the number of packet // N1 is the size of each packet
cp_size=9;%round(N1/4);
a=1;
F=dftmtx(N1);
index = [-3*a+j*3*a;-a+3*j*a;a+3*a*j;3*a+3*j*a;-3*a+j*a;-a+j*a;a+j*a;3*a+a*j;-3*a-a*j;-a-j*a;a-j*a;3*a-j*a;-3*a-3*a*j;-a-3*a*j;a-a*3*j;3*a-3*a*j];
ofdm_symb=6;
... |
function [gc,f]=projectionMerge(spikeFeatures,initIdx,varargin)
%merge clusters in a group that have to be merge based on the residuals between spikes and templates.
%synthax : [gc,f]=projectionMerge(spikeFeatures,initIdx,varargin)
%input:
% - spikeFeatures : spike features ()
% - initIdx : the clus... |
%% RESOLUCION PROBLEMAS DE CONTORNO TIPO DIRICHLET [0,1]
%---------------------------------------------------------------------
% [x,u]=dirichlet(fa,fb,fc,ff,alfa,beta,n)
%---------------------------------------------------------------------
% a(x)u''+b(x)u'+c(x)u=f(x) con x en (0,1)
% u(0)=alfa, u(1)=beta
%----... |
%Nombre de dents; pista:120 dents
clc;
I = imread('wheel.bmp');
BW = rgb2gray(I);
B = BW > 1;
F = imfill(B,'holes');
imshow(F);
radi = 15;
SE = strel('disk', radi);
E = imerode(F, SE); %erosionem la imatge F
radi2 = 16;
SE2 = strel('disk', radi2);
C = imdilate(E, SE2);
figure;imshow(C);
NF = F& (not(C));
figure;ims... |
function Dist1=mixHD1(Code1,newMask1,Code2,newMask2)
for m=1:3600
t1=1+(m-1)*64;
t2=m*64;
t3=floor((m-1)/12)+1;
t4=1+(t3-1)*64;
t5=t3*64;
Dist1(m)=HDR(Code1(:,(t1:t2)),newMask1(:,(t4:t5)),Code2(:,(t1:t2)),newMask2(:,(t4:t5)));
end |
%% fn_gettrend
%% Syntax
% [trend X beta] = fn_gettrend(y[,ind][,order][,options])
%% Description
% Estimates a slow trend for y
% it is possible to estimate it based on given indices only
%
% Inputs:
% - y signal
% - ind indices where there is supposed to be equal to baseline
% - order number of... |
%% Algoritmo de Euclides para P-adicos
%
% Algoritmo de Euclides para $Q_{p}[x]$
%
%
%
path(path, 'Algorithms');
path(path, 'Classes');
clear
%% $$ Q_{11} \: Ej1 $$
a = 48;
b = 24;
p = 11;
Qp = Padics(p);
fprintf("a = %s\n", Qp.padicsshow(Qp,a));
fprintf("b = %s\n", Qp.padicsshow(Qp,b));
gcd = euclid(a,b,Qp); % -3... |
%% FLAGS
DEBUG = 1; %no devices, just run with data
SVM = 1; %1 for 2-class, 0 for threshold
SHORT_FTR = 1; % 1: small feature set
%% Set up SVM
model_path = 'C:\Users\Ali\Documents\ISML\MEA Data\20170718_400_0_CL\twoclassmodel-e10.mat'
model_file = load(model_path);
model = model_file.best_model;
mus = model_file.mu... |
function [U,errors]=genSolveScalarBVP(bvp,info,verbose,varargin)
if verbose>=2, fprintf('*** Solving B.V.P. problem\n');end
tstart=tic();
U=bvp.solve(varargin{:});
tcpu=toc(tstart);
if verbose>=2
fprintf(' -> ndof (number of degrees of freedom) = %d\n',length(U));
fprintf(' -> solved in %.3f(s)\n',tcpu);
end
err... |
function P6
%% Fuel lean
% phi = 0.6, 0.8
phi_lean = [0.6, 0.8];
R = 0.082; % Gas constant in (L atm / K mol)
T = 1000; % temperature in Kelvin
N_lean = 9.52 + phi_lean; % total moles in lean rxn
K1 = 3.65*10^(-5); % equil constant for CO2 dissociation
K2 = 4.25*10^(-5); % equil constant for H2O dissociation
Kp = 0.... |
function stopOnlineTracking
% stopOnlineTracking (no arguments)
% Stops the periodic timer event that runs the online tracking algorithm.
% See Also: 'startOnlineTracking'
global MTT; %multi-target tracking run-online variables
if isempty(MTT)
error('no MTT: perhaps not started?');
end
stop(MTT.timer)... |
function [relativeInterfaceArea] = interfacePerVolume(...
diskCenters, diskRadii, gridRF)
%Computes the volume fraction of microstructures with disk exclusions
% diskCenters: clear
% diskRadii: clear
% gridVectorX/Y: specification of macro-cell edge lengths
A0 = zeros(gridRF.nCells, ... |
function [] =Tool_FA(CmdFile)
% This is the tool to do FA (forced alignment)
% Generally, the INPUTS are:
% 1. A set of HMM models previously trained from "train FA" step
% 2. A monophone HMM list. This list should cover all the phones
% including or not including "sp".
% 3. A pronunciation dictionary. This ... |
clf;clear all; close all;
% Generate qpsk signal
N = 5000;
sig = randi([0,1],1,N);
sig((sig==0)) = -1;
fs = 1e6;
f_DAC = 16;
f_DMA = 8;
load('./filter/IIR_filter');
group_delay = 7; % gorup delay of the IIR filter
srrc_16 = srrc_pulse(16,5,0.3);
% transmit branch
mod_sig_real = trans_branch(sig, f_DAC, srrc_16, f_D... |
function MonteCarlo_PPfunctions(DataNames,spots_data,CellNames,save_dir_aux)
% Monte Carlo study of summary statistics F, G and K.
%
% DESCRIPTION
%
% Monte Carlo simulations are used to find statistical correlation in the
% standard point process functions F, G and K. No edge correction used in
% this fun... |
function [ barNum ] = getBarbyDate( obj, year, month, day )
%getBarbyDate 根据时间(年月日),获取在此时间点后的第一根Bar的标号
% year,month,day:年月日,默认为1
% ver 1.0, by zhanghang, 2013/05/08
if ~exist('month', 'var'), month = 1; end
if ~exist('day', 'var'), day = 1; end
dateNum = datenum(year, month, day);
left = 1;
right = length(obj.ti... |
clear; clc;
load('coefficients_projection_x_D_80.mat')
f_sampled = f(1:50);
N_snaps = linspace(1,7200,7200);
[N_SNAPS, F_SAMPLED] = meshgrid(f_sampled, N_snaps);
%%
h1 = contourf(N_SNAPS, F_SAMPLED, abs(squeeze(c(1,3,1:50,:))'),'LineStyle','none');
colormap hot;
colorbar;
%% SPOD Parameters
Nfreq = 512;
Novlp =... |
function [] = show_scans_from_bag(path_to_bag, msg_type, msg_topic)
%SHOW_SCANS_FROM_BAG Summary of this function goes here
% Detailed explanation goes here
bag = rosbag(path_to_bag);
grid on;
switch(msg_type)
case 'scan'
bag_select = select(bag, 'Topic', msg_topic);
scans_msgs = readMessages(ba... |
function res = opdracht_3_versie_2_CHECK(apStudentSol)
res = 0;
%%========== PLACE SOLUTION IN COMMENTS HERE
% % % % % % % lengteA = 200;
% % % % % % % lengteB = 190;
% % % % % % % result = lengteB == lengteA;
%%==========
%% FILL nameVars WITH VARIABLES PRESENT IN SOLUTION FILE THAT THE STUDENT
checkingVar.nameVars... |
function out_transform = fitSquareTransform (convexImage, showIntermediate)
assert (islogical (convexImage), 'Input image must be of type logical');
assert (showIntermediate == 1 | showIntermediate == 0,...
'Intermediate result flag must be a true or false value');
[~, num_shape] = bwlabel (co... |
% Script for testing ad-hoc McStas load routines
% 1D-load:
figure
[x,y,err,xlab,ylab,titl]=Mc1Dload('lmonsrc.sim');
errorbar(x,y,err)
title(titl)
xlabel(xlab)
ylabel(ylab)
% 2D-load:
figure
[x,y,data,z,xlab,ylab,titl]=Mc2Dload('psd.sim');
imagesc(x,y,data);
set(gca,'ydir','normal');
colorbar
xlabel(xlab)
title(titl)... |
function s=spec(c)
n=length(c);
ns=(n-1)/2;
s=zeros(1,ns);
s(1)=abs(c(1));
for k=1:1:ns
s(k+1)=sqrt(c(2*k)^2+c(2*k+1)^2);
end |
function [ txt, txt2 ] = rptSimple( nav, varargin)
% 计算常见指标,输出到txt。需要matlab2014版
% [ txt, txt2 ] = rptSimple( nav, varargin)
% nav:净值曲线
% benchmark: 如有,位置必须是第二个
% 用 varname, varvalue 的形式输入以下变量:
% rfr:无风险收益,默认5%
% period:数据周期,可取如下值: d365, d360, d245, w, m, q, y, 默认为d245
% benchmark:如有,则多算一些相对收益的指标,否则不算
% -----... |
function [PP_CFG, PP_DATA] = KR_postprocessing(PP_CFG, PP_DATA, CFG, DATA, test_idx)
PP_DATA.tests{test_idx}.test_name = DATA.tests{test_idx}.test_name;
if ~isfield(DATA.tests{test_idx}, 'reaction_time')
PP_DATA.tests{test_idx}.key_factor_name = PP_CFG.tests{test_idx}.key_factor_name;
PP_DATA.tests{test_idx}.... |
function [fin_index] = final_index(sen_index,boundry,TIME_SLOT,SEN_NUM)
[row, col] = size(sen_index');
f_row = row * TIME_SLOT * boundry;
step = length(sen_index);
fin_index = zeros(f_row, col);
for dd = 1:1:boundry
global_offset = (dd-1) * TIME_SLOT * SEN_NUM;
temp_common = (dd-1) * TIME_SLOT * step;
for t... |
function ha = shMNum(M, varargin)
% Show matrix with number.
%
% Input
% M - matrix, n1 x n2
% varargin
% show option
% dis - display type, {'imagesc'} | 'contour'
% clMap - color map, {'gray'}
% bar - bar flag, 'y' | {'n'}
% eq - axis equal flag, 'y' | {'n'}
% P ... |
function [error] = RMSE(img1, img2)
img1 = double(img1);
img2 = double(img2);
img1_norm = img1 - min(img1(:));
img1_norm = img1/max(img1(:));
img2_norm = img2 - min(img2(:));
img2_norm = img2/max(img2(:));
[m n] = size(img1);
error = sqrt(sum(sum((img1_norm - img2_norm).^2))/(m*n));
end |
function filtered = filter_gps_data(data, classes)
filtered = cell(size(classes,1),size(data, 2) + 3);
% append data to classes
ids = str2double(classes(:, 1));
gpsIds = str2double(data(:, 1));
for i = 1:length(ids)
j = gpsIds == ids(i);
if (sum(j) > 0)
filtered(i... |
clear
close all
clc
rng(2)
%% Parameters
% Dimension
n = 100; % observations
d = 3; % features
%Noise
sigma = 2;
Nmc=500;
n_iter = 40;
time_em = zeros(1,Nmc);
time_ils = zeros(1,Nmc);
time_fgfa = zeros(1,Nmc);
for ind_mc = 1:Nmc
% Ground truth sphere
c= randi(10,1,d)-5;
r = r... |
%this file creates the Expected Improvement acquisition function
function val=acqEI(hyp, fOpt, inf, mean, cov, lik, xm, ym, xs)
[mu,s2] = gp(hyp.gp, inf, mean, cov, lik, xm, ym, xs);
xi = hyp.acq;
z0 = (mu - fOpt-xi)./sqrt(s2);
Phi = (mu- fOpt).*normcdf(z0) + sqrt(s2).*normpdf(z0);
res = Phi;
%val = log(Phi);
for ... |
function [final_dynamic_path,CFO_calibrated]=ExtractDynamicPath(test_csi_file, static_csi_file,antenna_number)
% Extract the dynamic path which is caused by the human movement
%
% test_csi_file: input csi file
% static_csi_file: static CSI measured during static time
% antenna_number: 1 or 2 or 3, represent the serial ... |
function ecogDrawFixation(d, colIndex)
%
% drawEcogFixation(display, [colIndex=1])
%
% Draws the fixation point specified in the display struct.
%
% HISTORY:
% 2005.02.23 RFD: wrote it.
% 2005.06.29 SOD: added colIndex for fixation dot task
% added largeCrosses options
% 2008.05.11 JW: added 'dot and '... |
function [ pixel_value_array ] = GetPixelValues( image, pixel_array )
%GETPIXELVALUES This function returns an array of values corresponding to
%each pixel in pixel_array
% This function receives an image and an array of pixels, in no
% particular order, and returns the image values at each of the pixel
% l... |
clear all
cityData= {'Lagos|ng','Jakarta|id','Bangkok|th','Nairobi|ke',...
'Rio de Janeiro|br','Accra|gh','Longyearbyen|no','Khartoum|sd'};
cityn=length(cityData);
DataM=zeros(8,39);
n=1:8;
for i=1:length(n)
[city country]=strtok(cityData{i},'|');
country=erase(country,'|');
key='70e9f383955e73... |
function client(port)
% provides a menu for accessing PIC32 motor control functions
%
% client_menu(port)
%
% Input Arguments:
% port - the name of the com port. This should be the same as what
% you use in screen or putty in quotes ' '
%
% Example:
% client_menu('/dev/ttyUSB0') (Linu... |
function [variants_nr] = GenDecrVar_Single_D (is_increase, tar, InputName,duration_tick)
% Partitioning the 'Generate Decrease' feature signal
% Consistent with the 'Detect Decrease' in Validation Functions
% the Function feeds back the generated variants' number
tar_l = length(tar);
SOURCE = tar(1:(tar_l-3));
fixste... |
% MATLAB/Octave script to plot graph for q14
MIN_X = 0;
MAX_X = 300;
MAX_X_DISPLAY = 10000;
MIN_Y = 0;
MAX_Y = 0.000005;
secondsPerStep = 10^(-9);
% Set up figure
disp("Plotting graph for q14...");
axis([MIN_X, MAX_X, MIN_Y, MAX_Y]);
hold on;
x = MIN_X:MAX_X_DISPLAY;
% Plot each curve
plot(x, log(x) .* secondsPerSte... |
function makeMeshPretty(mshHandle,data);
%origValues = get(mshHandle,'faceVertexCData');
origValues = data;
validInd = find(~isnan(origValues));
origValues(isnan(origValues))=0;
mesh.uniqueVertices = get(mshHandle,'vertices');
mesh.uniqueFaceIndexList = get(mshHandle,'faces');
conMat = findConnectionMatrix(mesh);
... |
function [payoff] = payoff_IF_same(S)
% S 是一个序列
% 看平沪深三百指数期权
% payoff 为三种情况:涨跌幅> 5% payoff = 0;
% 涨跌幅为5% ~ 1%: payoff = 5%;
% 涨跌幅为1%以内:payoff = 10%;
upper = 1;
middle = 0.5;
S0 = 1;
K1 = 0.05;
K2 = 0.01;
ST = S(:, end);
payoff = zeros(size(ST));
payoff(abs(ST - S0) < K2) = upper;
payoff(abs(ST - S0) <= K1) = midd... |
%% Polyphase filter
clc;
%% Initializing the variables
% From the given information the values of x and h are initialized.
% y is given by the convolution of x and h.
x=[16,13,6,-3,-9,-1,-10,-6,-2,-0.3];
h=[-0.1,0,0.3,1,0.3,0,-0.1];
figure;
subplot(2,1,1);stem(x);
title("Signal x(n)");
xlabel("Number of sampl... |
% convert between video / image sequences: https://www.mathworks.com/help/matlab/examples/convert-between-image-sequences-and-video.html
% this file is used to import the video
vid = VideoReader('input5.mp4');
scale = 1/2;
i = 1;
while hasFrame(vid)
im = readFrame(vid);
im = imresize(im,scale);
imname = s... |
%% Precision recall diagram drawing, 2.0 Beta version
%This script is supposed to run on two binary histograms, that
%will be matched against one another. The variables that
%are assumed to be in the workspace are:
%Histogram1, from which a reference database is built
%Histogram2, for choosing a query place
%pos1, gr... |
%EM
N1=1000;
N2=1000;
mu1=[2,2];
mu2=[1,5];
sigma1=[2,0;0,0.1];
sigma2=[1,0.5;0.5,1];
X1=mvnrnd(mu1,sigma1,N1);
X2=mvnrnd(mu2,sigma2,N2);
X=[X1;X2];
% hold on;
% scatter(X1(:,1),X1(:,2),'.');
% scatter(X2(:,1),X2(:,2),'.');
[label,model,llh]=emm(X);
hold on;
showpoints(label,model,X);
showbounds(label... |
function addFiduciaryMark(imname)
if (nargin == 0) || isempty(imname)
[fn,pn] = uigetfile('*.tif','Select calibration image');
imname = fullfile(pn,fn);
end
[pn,fn,ext] = fileparts(imname);
I = imread(imname);
if (isa(I,'uint16')) && (max(I(:)) <= 2^12)
% probably a 12 bit image
I = im2uint8(I*16);
e... |
function [value, isterminal, direction] = ode_events(~, S)
table_width = 1.17; % m
table_length = 2.34; % m
% speed_threshold = 0.1; % m/s (about 1 in/s)
global radii ball_dist_event_dirs
ball_count = length(S)/4;
x = zeros(1,ball_count);
y = zeros(1,ball_count);
vx = zeros(1,b... |
function [optimal_paras, test_all_errs, run_times] = tune_parameters_refined(L, X, y, model)
% rng('default');
optimal_paras = zeros(4, 4);
test_all_errs = ones(4, model.n_repeats);
run_times = zeros(4, model.n_repeats);
optimal_paras(:, 4) = model.varepsilon;
% choose tau_A
for i_tau_A... |
function varargout = DisplayLogFile(varargin)
% DISPLAYLOGFILE MATLAB code for DisplayLogFile.fig
% DISPLAYLOGFILE, by itself, creates a new DISPLAYLOGFILE or raises the existing
% singleton*.
%
% H = DISPLAYLOGFILE returns the handle to a new DISPLAYLOGFILE or the handle to
% the existing singleton... |
%% Which experiment do you want to analyze?
experiment_name='1A';
%version = '1';
%experiment_name='1B';
%experiment_name='1C';
version = '4';
MCRL_path='/Users/Falk/Dropbox/PhD/Metacognitive RL/MCRL/';
fig_dir=[MCRL_path,'matlab_code/dataAnalysis/figures/']
%eval(['import_data_exp',experiment_name,'_v',version])
%... |
function [c, dp] = bezier_der1(b,t)
%izracuna tangentni vektor na bezierjevo krivuljo v t
n = length(b);
dp = b(:,2:end)-b(:,1:(end-1));
dp = (n-1)*dp;
c = deCasteljau(dp,t);
end |
function Assignment2_SeamCarving()
% Best Practices
clc, close all
%im = imread('c:/material/EE8374CV/Assignment2/hwkHybridImages/data/view.jpg');
im = imread('c:/material/EE8374CV/Assignment2/hwkSeamCarving/Dallas-Skyline.jpg'); % Read the image
im = im2double(rgb2gray(im)); % Convert to grayscale & ... |
function x=fgausspivparcial(n,A)
%EScalonamento
for k=1:n-1
% retorna a matriz expandida A com linhas trocadas.
[A]=fpivotacaoparcial(k,n,A);
% Escolhe a melhor linha i=k, antes de efetuar a eliminacao
for i=k+1:n
aux=A(i,k)/A(k,k);
for j=k+1:n+1 %operações com mínimo de colunas
A(i,j)=A(i,j)-... |
%function to plot graph between Date-Time and Wind Speed
clear;
clc;
filename = '/Users/tirth_8205/Desktop/Ahmedabad University/Internship [May - July,2020]/CDC-Internship/Raw Data/Raw Met Data.dat';
startRow = 2;
formatSpec = '%10f%7f%7f%8f%7f%f%[^\n\r]';
f1 = fopen(filename,'r');
%scanning of data
dataArray = textsc... |
function Params = stimdefAREVCOR(EXP);
% stimdefARevcor - definition of stimulus and GUI for ARevcor stimulus paradigm
% P = stimdefARevcor(EXP) returns the definition for the ARevcor (moving noise)
% stimulus paradigm. The definition P is a GUIpiece that can be rendered
% by GUIpiece/draw. Stimulus definition... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.