text stringlengths 8 6.12M |
|---|
function Ahat= DICASymm_recur(y, P) % dimension d, num trails
% second version of recursion P'MP
n = size(P,1);
d = size(P,2);
if (d==0)
Ahat= [];
end
if (d==1)
Ahat= P;
end
if(d>1)
V = sqrt(-1);
while ~isreal(V)
% calculated M
phi = randn(n,1);
G1_phi = G1(phi,y);
... |
close all
clear all
clc
bits = [1 0 1 0 0 0 1 1 0]; %sequence binaire
e = 1; % Nbr de bits par seconds
Tb=0.1;
fc=0.8; %frequence de la porteuse
V=1;
[t,x] = rz(bits,e); %gerenaration d'un code RZ
%*******Modulation : ***********
Ac1=2; % Amplitude pour le bit 1
Ac2=1; % Amplitude pour le bit 0
c1=Ac1*cos(2*pi*f... |
function y = logistic(x, p)
y = p(1) + p(2)./(1+exp(-p(3) * (x-p(4))));
endfunction
|
function [ Xemotion,d2,s ] = emotionFeatSelector( X, d, nFeat, emotion )
%SINGLEEMOTIONCLASSIFIER Summary of this function goes here
% Detailed explanation goes here
op.m = nFeat;
op.show = 0;
op.b.name = 'fisher';
d2 = d;
for i = 1:length(d)
d2(i) = length(emotion)+1;
for j = 1:length(emotion)
... |
function u = benchmark()
global rmat;
global predInd;
Pnum = sum(rmat~=0,1);
Psum = sum(rmat,1);
Pmeans = Psum./Pnum;
u = full(Pmeans(predInd(:,2)))';
end |
function myKeyCheck
% OSで共通のキー配置にする
KbName('UnifyKeyNames');
% いずれのキーも押されていない状態にするため1秒ほど待つ
tic;
while toc < 1; end;
% 無効にするキーの初期化
DisableKeysForKbCheck([]);
% 常に押されるキー情報を取得する
[ keyIsDown, secs, keyCode ] = KbCheck;
% 常に押されている(と誤検知されている)キーがあったら、それを無効にする
if keyIsDown
fprintf('無効にしたキーがあります\n');
... |
function [focs, xcentrs, ycentrs, ars, skews, bestFfinal, bestXfinal, bestYfinal,bestAR,bestSkew]=convertOutSelfCalibFormat(allsols, bestslns)
numElements=size(allsols,2);
focs=zeros(numElements,1);
xcentrs=zeros(numElements,1);
ycentrs=zeros(numElements,1);
ars =zeros(numElements,1);
skews=zeros(numEle... |
function N = Newtons_1D_Opt(tol)
xn = .25;
xm = 0;
err = 1;
N = 0;
while err > tol
xm = xn - (fd1(xn) / fd2(xn));
err = abs(xm-xn);
xn = xm;
N = N+1;
end
% functions we are trying to optimize
function val = f(x)
val = .5 + x*exp(-(x^2));
% first derivative of the function
function val = fd1(x)
val ... |
% File: Example8_05.m for Example 8-5
clear;
% Select values for PedBw, f, B, dmile, diam, and Tar, Tf, Tlna, Trx, Gf
% and Glna to desired values.
PedBw = 36;
f = 4e9;
B = 30e6;
dmile = 24784;
% diam has units of meters
diam = 10*(0.3048);
Tar = 26;
Tf = 6;
Tlna = 40;
Trx = 2610;
Gf = 0.98;
Glna = 100000;
d = 160... |
function [output2,stitched] = padstitch(displacement,img1,img2_T)
h1 = size(img1,1); % vertical y axis,
len1 = size(img1,2); % horizontal x axis
h2 = size(img2_T,1);
len2 = size(img2_T,2);
x_d = displacement(1,1);
y_d = displacement(2,1);
if y_d > 0
output1 = cat(1,zeros(y_d,len1,3),img1,z... |
close all; clear all; clc;
H = 50;
W = 256;
g = zeros(50,256);
%g(:,1:255) = 255- |
function [num_nodes, num_nodes_per_element, LM, coordinates] = mesh(L, num_elem, shape_order)
num_nodes = (shape_order - 1) * num_elem + 1;
% for evenly-spaced nodes, on a 3-D mesh. Each row corresponds to a node.
coordinates = zeros(num_nodes, 3);
% in 1-D, the first node starts at (0,0), and the rest are evenly-sp... |
function [ output] = update_property(property,branches,objective_function)
t=length(property);
[m,n]=size(branches);
if objective_function==1
ma=max(branches(:,n));
branches(:,n)=ma-branches(:,n);
for i=1:t
s=0;
for j=1:m
if branches(i,n-2)==i
s=s+branch... |
% Amey Kulkarni (PhD Student@EEHPC,UMBC)
% Floating point to Fixed Point conversion
% Please do not misuse the code ( such as a Home work solution)
function [fix_no]=float2fix(float_no,f)
% float_no: Floating Number to be Converted
% f : Bit Resolution
% fix_no: Converted fixed point number
[float_r,float_c]=si... |
clear
clc
close all
%Read in the original image
img=imread('cameraman.tif');
subplot(4,3,1),imshow(img);
title('original')
[m,n]=size(img);
%transform the image from spaital domain to frequency domain
G=fftshift(fft2(img));
%get the motion blur frequency domain filter
H=zeros(m,n);
for u=1:m
for... |
% This is the cost function for fmincon
% fun is the value of the cost function, and g is its gradient
function [fun,g]=costfmincon(x);
global x0 C0
fun=(x-x0)'*inv(C0)*(x-x0);
g=2*inv(C0)*(x-x0);
|
clc;
clear;
close all;
% src = 'E:\Write_identification\dataset\icdar2013\experimental_dataset_2013';
% dstTrain = 'E:\Write_identification\dataset\icdar2013\verticalCut';
% src = 'E:\Write_identification\dataset\icdar2013\icdar2013_benchmarking_dataset';
% dstTrain = 'E:\Write_identification\dataset\icdar2013\icdar20... |
function [lg] = len_grad(T)
% input: mean temperature, 3d field
% output: centered differences squared, 3d field
% first and last rows are NaNs because differences in y derivatives cannot be calculated there.
lg = 0.25 .* ( circshift(T, [0 1 0]) - circshift(T, [0 -1 0 ]) ).^2 + 0.25 .* ( circshift(T, [1 0 0]) - circ... |
%%% IMAGING
%PARAMETERS
numofvoxels=1;
numofpoints=1000;
numoftra=128;
pta=4; %points to average
%change delay for phocs
usstart=4;
usend=1000;
threshcutoff=10;
% tic
% % load sonixdata (all voxels per channel)
% % RF = zeros(numoftra, );
% for i=0:numoftra-1
% [S,ERRMSG]=sprintf('CH%03d.daq',i);
% fid = f... |
function fit = ebbsmv01_raymodified(x,y,param) ;
%
% Last edited: 6/12/2000
%
% Copied from ebbsmvdef
%
% Calls ebbsmvparam with default values of tuning parameters,
% though non-default values can be specified in
% argument "param" which is a structure
% USAGE: fit = ebbsmvdef(x,y,param) ;
%
% Example: fit... |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% This function initializes the weights of the autoencoder away from %%
%% the ground truth A_star. Each row of W is initialized at a fixed %%
%% distance (delta) away from the corresponding column of A_star %%
%% Inputs: ... |
function Sub1FunctionA()
disp('This is Sub1FunctionA');
end |
function leaflet = get_free_edge_ranges_bead_slip(leaflet, tree_n_start)
%
% Returns two 2d arrays of indices
%
% Input:
% leaflet Parameter struct
%
% Output:
% free_edge_idx_left 2d array of left chordae indices of the implicitly defined leaves.
% The i-th leaf is not incl... |
function [pPL, resus] = delVcalc(lambda, e, N)
global Isp g0 Mpay W Udes
%N = round(N);
if size(lambda,2) == 1,
pPL = (lambda/(1+lambda));
num = (pPL^(1/N))*(1-e) + e;
U = log(1/num);
resus = U*Isp*g0*N;
end
if size(lambda,2)>1,
pPL = (lambda./(1+lambda));
num = (pPL.^(1./N)).*(1-e) + e;
U ... |
clear all ;
close all;
clc;
Te=2E-3; % période d'échantillonnage de la commande
Tc=10e-3; % période d'échantillonnage de génération de consigne
Delta=10; %% écart initial entre les loco au démarrage
%% Initialisation du générateur de trajectoire
% Génère des consignes de position et de vitesse cohérent... |
global Geom
global Controls
global Aero
global Mass
global Eng
global Lgear
global Atm
global Ap
global Sensors
global Flight_latitude Flight_longitude
global Flight_Trimming Flight_AutoPilotON Flight_WindGustON Flight_TimeStep Flight_SensorsON Flight_DamperON
global Flight_LoiterRadius Flight_LoiterMode Fli... |
8clear all
close all
clc
%% Our Data
% Flow1 = pa_dtfanalysis('MW-BS-2010-07-14-0004.hrtf'); age1 = 65;
% Flow2 = dtfanalysis('MW-XX-2010-07-15-0004.hrtf'); age2 = 80;
% Flow3 = dtfanalysis('MW-X2-2010-07-15-0004.hrtf'); age3 = 76;
% Flow4 = dtfanalysis('MA-DE-2010-07-19-0001.hrtf'); age4 = 65;
% Flow5 = dtfanalysis('... |
y =[ 114.9410 80.8000 67.7680 60.8880 56.6530 53.8000 51.7590];
x= [1.2500 1.5000 1.7500 2.0000 2.2500 2.500 2.7500];
z=fittype('poly6');
c=fit(x(:),y(:),z);
step_size=0.001;
z3=1:step_size:3;
plot(z3,c(z3));
hold on;
plot(x,y,'d');
legend('Fitted Curve','Data'); |
function bins = binsort(x, n)
%BINSORT Simulate sorting by binning.
% BINS=BINSORT(X,N) breaks the vector X down to N bins. Each bin has a
% range of x values: the range [MIN(X),MAX(X)] is sub-divided into N
% equidistant intervals (bins). BINS is an Nx1 cell array of the
% corresponding X-sub-vector indic... |
clear;
fid=fopen('/home/scw4750/github/IJCB2017/liufeng/data/protocols/protocols_2parts_bbox/ir/probe1.txt','rt');
% fid=fopen('probe.txt','rt');
list=textscan(fid,'%s');
fclose(fid);
fid=fopen('/home/scw4750/github/IJCB2017/liufeng/data/protocols/protocols_2parts_bbox/ir/probe1_with_label.txt','wt');
% fid=fopen('prob... |
function [APs,t,En,Ei,Is,Xn,Xi,In,Ii] = resp(tspan,Fs,M,S)
%RESP Test the response to a stimulus
% [APs,t,En,Ei,Is,Xn,Xi,In,Ii] = resp(tspan,Fs,M,S)
h = 2e-6;
P = parameters(tspan(1),tspan(2),h,Fs,0,1);
tspan = [0e-3 2e-3];
h = 1e-6;
APs = simPatch(P,S,M.E,M.GN,M.GI,M.A,M.B,M.X0);
load data.out
t = data(:,1);
En =... |
function pt = steinerPoint(varargin)
%STEINERPOINT Compute steiner point (weighted centroid) of a polygon.
%
% PT = steinerPoint(POINTS);
% PT = steinerPoint(PTX, PTY);
% Computes steiner point of a polygon defined by POINTS. POINTS is a
% [N*2] array of double.
%
% The steiner point is computed the s... |
function [ Mask_out ] = compMask( tf,Pnei,N,sumM )
% [ Mask_out ] = compMask( tf,Pnei,N )
%
% Compute the mask for signal reconstruction
%
%
% INPUT:
% tf : ridges position
% Pnei : mask width
% N : number of frequency bin
%
% OUTPUT:
% Mask_out : binary mask
%
% Author: Q.Legros (quentin.legr... |
%% Current Controller Design
% ########################################################################
% Design control parameters for a grid-tied inverter
% Description
% - ACC (converter-side current control)
% - DVC
% - PLL
% Input:
% - [obj] inverter definition
% - [obj] grid definition
% - [obj] contr... |
% Spherical Harmonics Y_lm (theta,phi)
%
% Normalization by the usual Quantum Mechanics conventions
%
% mikael.mieskolainen@cern.ch, 2017
function Y = sphericalharmonics(theta,phi,l,m)
% Get the associated legendre polynomials
P = legendre(l, cos(theta));
Y = (-1)^m*sqrt( (2*l+1)/(4*pi)*(factor(l-m)/fact... |
% test splitting
%%
fm = 1.8282e9; % TD11
psg.freq(fm);
%%
% 30 dB atten on the output, cable loss ~ 3 dB
% psg.power(3);
psg.power(-3);
%% RF freq sweep
fms = linspace(1.82e9, 1.88e9, 100);
pow = 2;
psg.power(pow);
psg.on
wls_all = {};
v1s_all = {};
whichRow = 'BT';
ind_dev = 6;
... |
clear all; clc; close all;
%%
load('test_data.mat');
rT = r;
gT = g;
% disp(gT); disp(rT);
xrange = [-0.5, 0.5];
yrange = [-0.5, 0.5];
zrange = [-0.5, 0.5];
th_range = [0, 2*pi];
l_axis = 0.1;
figure;
% trplot(rT, 'rgb', true, 'thick', 2.0, 'length', l_axis); hold on;
% trplot(gT, 'rgb', true, 'thick', 2.0, 'length',... |
function hdr = readImgHdr(fname)
%READIMGHDR Read header information for neuroimaging data.
%
% H = READIMGHDR(FILENAME)
%
% Optional dependencies:
%
% SPM http://www.fil.ion.ucl.ac.uk/spm
% MRtrix3 http://www.mrtrix.org
%
% See also: READIMGDATA, WRITEIMGDATA.
%
% Author: Kristian Loewe
if iscel... |
function Result = Func_ObjStruct2Img(dd,bw)
n = length(dd.PixelIdxList);
finalSingleObj = cell(n);
for i = 1:length(dd.PixelIdxList)
pic = false(size(bw));
pic(dd.PixelIdxList{i}) = true;
finalSingleObj{i}= pic;
end
Result = finalSingleObj;
end |
addpath( './utils' );
addpath('../libsvm/libsvm-3.22/matlab/')
clear
close all
% file_list={'plant','psortPos', 'psortNeg', 'nonpl', 'sector', 'segment','vehicle','vowel','wine','dna','glass','iris', 'svmguide2','satimage', 'usps'};
file_list={'iris'};
for i=1:length(file_list)
data_name=char(file_list(i));
... |
%% init consts
SRC_COL=2;
INIT_COL=4;
END_COL=5;
%% OUT
list_logs = dir('*.log') ;
filename = list_logs(end).name ;
outrawdataset = dlmread(...
filename,...
' ', 1, 0) ;
outdataset80211 = outrawdataset( outrawdataset(:,6) == 1,1:end-1) ;
fprintf('(%s) Events: <%d> ---> selected : <%d>\n', ...
filename, ..... |
function ShowROC(RocStructure, extrastring, Color, LineWidth)
%function ShowROC(RocStructure, extrastring, Color, LineWidth)
%
if(nargin == 1)
plot(RocStructure.normfp, RocStructure.normtp);
end
if(nargin == 2)
plot(RocStructure.normfp, RocStructure.normtp, extrastring);
end
if(nargin == 3)
plot(RocStructure.n... |
function [ difference, index ] = find_closest( value, vector )
% Find closest element to 'value' inside 'vector'.
% Return difference between 'value' and closest element and index of that
% element.
[difference, index] = min(value - vector);
end
|
function curl = fftCurl(u)
% Calculates the spectral curl of a vector field, actual curl
% must be scaled by 2pi/L.
N=size(u);
i=[0:N(1)/2-1, -N(1)/2:-1];
j=[0:N(2)/2-1, -N(2)/2:-1];
k=[0:N(3)/2-1, -N(3)/2:-1];
[ii,jj,kk]=meshgrid(i, j, k);
omega=cat(4, ii, jj, kk);
curl=spCross(1i*omega, u);
end |
addpath('/home/ohadsh/work/python/thesis/matlab/');
sampling_factor = 4;
start_line = 1;
keep_center = 0.05;
W = 256;
H = 256;
disp(['Working on radom mask - ', num2str(sampling_factor)])
size_dat = W * H;
basic_path = '/media/ohadsh/Data/ohadsh/work/data/T1/sagittal/';
tt = 'train';
N_imgs = 5;
[real_all, imag_all, ... |
function showPop(pop, row, col)
% Assumes a population of 20 pictures
% pop is a cell-array of pictures.
% assumes that a figure is defined and hold is on.
global metricVec;
global fitnessVec;
[temp1, temp2] = sort(metricVec);
pop = pop(temp2);
fitnessVec = fitnessVec(temp2);
globa... |
% This is material illustrating the methods from the book
% Financial Modelling - Theory, Implementation and Practice with Matlab
% source
% Wiley Finance Series
% ISBN 978-0-470-74489-5
%
% Date: 02.05.2012
%
% Authors: Joerg Kienitz
% Daniel Wetterau
%
% Please send comments, suggestions, bugs,... |
%% SETPARS - initializes parameters for use as input
%%
%% Jon Bolmstedt 2000-08-12
initvvx; %Editboxar -> variabler
par(1) = rho;
par(2) = cpc; %cp J/kg,K
par(3) = fc; %kall m3/s
par(4) = fh; %varm m3/s
par(5) = k; %k W/m2K
par(6) = tcin;%Tkin
par(7) = thin;%Tvin
par(8) = A; %m2
par(9) = V; %m... |
function dydt = f(t, y, p)
%zeilinger Arabidopsis
eval(p);
dydt = [
%1 mRNA of LHY
amp*force * q1 * y(13) + (n1 * y(9)^a) / (g1^a + y(9)^a) * (g7^h) / (g7^h + y(16)^h) * (g8^ii) / (g8^ii + y(19)^ii) - (m1 * y(1)) / (k1 + y(1));
%2 Cytoplasm LHy
p1 * y(1) - r1 * y(2) + r2 * y(3) - (m2 * y(... |
%Created on Wed Apr 29 17:21:49 2020
%@author: Zachary
function [M_1,M_2,M_3,M1_ind,E1u,E1v,E2u,E2v,E3u,E3v]= SampleSplitting(M, p)
n = length(M);
p_prime = p / (4 - p);
M_1 = zeros(n,n);
M_2 = zeros(n,n);
M_3 = zeros(n,n);
M1_ind = zeros(n,n);
labels = [1; 2; 3];
p_labels = [1 / 4; 1 / 4; 1 / 2];
E1u=[];E1v=[];E2u=[... |
clear all ; close all ;
subs = {'alex','dina','genevieve','jeremie','russell','sukhman','tegan','valerie'};
source_folders = {'den_retino_allstims_01','den_retino_allstims_02','den_retino_gamma_01','den_retino_gamma_02','den_retino_movie','den_retino_rest'};
clean_fmri_names = {'bp_clean_retino_allstims_01','bp_... |
rng(123456)
% Random bits
d = randi([0 1],1024,1);
% BPSK modulation
syms = pskmod(d,2);
% Square-root raised cosine filter
filterCoeffs = rcosdesign(0.35,4,8);
tx = filter(filterCoeffs,1,upsample(syms,8));
p=1
ContinueTransmit = 1
%radioTx = comm.SDRuTransmitter('Platform','N200/N210/USRP2','IPAddress','192.168.1... |
function [] = runQValue(parameterFile, outcomeFile, choiceFile,...
filenameQ,filenameP,choiceRule)
%generate nrIt sample for all subject (rows) in paramterFile
%read in the outcome, choice and start values input files for all subjects
parameter = csvread(parameterFile);% alpha, temp, beta, gamma, epsilon
outcome... |
%% Local Intensity-fitted Method, subclass of threshold method
% Gordon Bean, May 2013
classdef LocalFitted < ThresholdMethod
properties
bins;
pvalue;
fdr;
fast;
full;
num_background_iters;
upper_threshold_function;
end
methods
% Construc... |
function pc = shift_reference(pc_plant, pc_pot, do_vertical_rotate)
% Shifts a point cloud to the standardised position
if do_vertical_rotate
pc = rotate_to_vertical(pc_plant, pc_pot);
else
pc = pc_plant;
end
pc = rotate_to_principal_axis(pc);
pc ... |
function varargout = Selection_GUI(varargin)
% SELECTION_GUI MATLAB code for Selection_GUI.fig
% SELECTION_GUI, by itself, creates a new SELECTION_GUI or raises the existing
% singleton*.
%
% H = SELECTION_GUI returns the handle to a new SELECTION_GUI or the handle to
% the existing singleton*.
%
% ... |
classdef ProblemSetup < handle
%PROBLEMSETUP Constructs a graph-related problem.
% This interface builds a Problem class that represents the
% computational graph problem at hand. The problem also serves as the
% back-bone of the finest level in a multi-level hierarchy.
%
% See als... |
function [q] = GetPrice_r(a_0, z_0, bd_0, cdf_x, ...
shk_a_grid, shk_z_grid, shk_a_num, shk_z_num, b_grid, ...
shk_a_step, shk_z_step, b_num, b_step_inv, a_x_step_inv, z_x_step_inv, ...
a_x_grid, z_x_grid, a_x_num, z_x_num, a_x_points, z_x_points, pdf_shk_a, pdf_shk_z, delta_grid, pdf_delta, num_delta, ...
... |
%% This script reads in, and subsequently averages nephelometer data
% Hourly-averaged and daily-averaged Bsp
close all; clear all; clc
%% %%%%%%% USER SWITCHES %%%%%%%%%%
sites = 2;
% 1 = international sites
% 2 = MAPLE sites
% 3 = all sites
Loc = 2:5; % Use this switch to select which sites you'd liek to process i... |
function box = point3dBounds(points)
%POINT3DBOUNDS Bounding box of a set of 3D points.
%
% BOX = point3dBounds(POINTS);
% POINTS is a N-by-3 array of points, each coordinate being given in a
% column. The result BOX contains extreme coordinates in the form:
% BOX = [XMIN XMAX YMIN YMAX ZMIN ZMAX].
%
% ... |
function [ regions ] = peakRegionBin(peaks,wids,ppp,scanDevs,maxRange)
%peakRegionBin Takes in a list of peaks and widths and generate binned regions
% INPUTS
% peaks = 1xn list of peak center locations
% wids = 1xn list of widths associated with each peak in peaks
% ppp = points per peak, i.e. should have wid/pp... |
% A routine that computes the reconstruction of the glottal excitation
% signal according to the vowel data generated by create_simulated_data.
% By default the routine will plot the reconstruction of the glottal
% excitation signal, and optional outputs include playing the glottal
% excitation signal and saving both t... |
close all;
clear all;
n_neur3 = 1000;
n_neur2 = 8;
n2_errors = zeros(1, n_neur2);
%for n_neur2 = 1:1:25
M = dlmread('train.csv',';',1,0);
n_params = length(M(1,:));
m = length(M(:,1));
n_last_tests = 1000;
labels = M(1:m-n_last_tests, n_params);
I = M(1:m-n_last_tests, 1:1:n_params);
I_test = M(m-n_last_tests+1:m, ... |
%Q1
k=1;
sys=tf([2*k 2*k],[1 9 18 0 0])
figure
rlocus(sys);
%Q2
k=1;
sys2=tf([1*k 9*k],[1 4 11 0])
figure
rlocus(sys2);
%Q3
a=.672;
k=2.36;
Gs=tf([0 1],[1 0 1])
GcGs=tf(conv([k k],[1 a]),[1 0 1 0])
sys3=feedback(Gs,1)
figure
step(sys3)
sys5=feedback(GcGs,1)
figure
step(sys5)
%Q4
k=1;
sys4=tf([10*k 3*k],[1 3 2 0]... |
function [phi] = step_basis(C,q_exp,Nx,Ny,N,Lx,Ly,x_grid,y_grid,final,x,y,dy,m_bct,m,dMu,jerror)
iter=1;
for j=jerror%1:size(q_exp,2)
cx=(C(1,1,j)+C(1,2,j)*sin(pi*x/Lx)+C(1,3,j)*sin(2*pi*x/Lx)+...
+C(1,4,j)*sin(3*pi*x/Lx)+C(1,5,j)*sin(4*pi*x/Lx)...
+C(1,6,j)*sin(5*pi*x/Lx)+C(1,7,j)*sin(6*pi*x/... |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Created: 15-Jul-2014 16:53:06
% Computer: GLNX86
% Matlab: 7.9
% Author: NK
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [dataHighPass,fltr]=ellipseFltr(semi,data)
%% get center, minor and major axis for ellipse
semix=10*ceil(max(nanmedian(semi.x,2)));
semiy=10*c... |
x_r=-10:0.001:0;
x_q=0:0.001:5;
x_f=5:0.001:10;
x=-10:0.001:10;
y_q=fQ(x);
y_r=fR(x);
y_f=fF(x);
y_qM=-fQ(x);
y_rM=-fR(x);
y_fM=-fQ(x)./(fR(x)~=0);
%%%%%%%%%%%
y_q2=fQ(x_q);
y_r2=fR(x_r);
y_f2=fQ(x_f)./(fR(x_f)~=0);
%%%%%%%%%%%%%%%%%%%
%
x_q_z1=fzero('fQ',6);
x_q_z2=fzero('fQ',0);
x_q_z3=fzero('fQ',... |
function soln = compute_econ_soln(params, h, T, nControlPts, c2, uGuess)
nSTEPS = T/h;
tspan = linspace(0, T, nSTEPS+1);
controlGrid = linspace(0, T, nControlPts);
u0 = uGuess(controlGrid);
ControlBounds = [0 Inf];
initState = params.k;
prob = EconomicProblem(params, ControlBounds);
prob.c2 =... |
function M = convectionUpwindTerm1D(u, varargin)
% This function uses the upwind scheme to discretize a 1D
% convection term in the form \grad (u \phi) where u is a face vactor
% It also returns the x and y parts of the matrix of coefficient.
%
% SYNOPSIS:
% M = convectionUpwindTerm1D(u)
%
% PARAMETERS:
%
%
% RETURNS... |
function [wls_peak, inds_peak, data_LPF] =...
findpeak_preprocess(wls, data, isUpOrDown,...
n_peaks, rto_peakToStd, d_wl)
% function [wls_peak, inds_peak] = findpeak_widescan(wls, data, isUpOrDown)
% find peaks from wide scans
%
% This function first subtract the LP-filtered d... |
%% Longstaff-Schwartz Method
function [Weights,price] = LSM_Estimator(Data,r,Settings)
price = 0;
W = 4; % The number of weights depends on whether we use volatility or not.
Tenor = size(Data,2) - 1;
N = size(Data,1);
Weights = zeros(W,1+Tenor);
gamma = exp(... |
function plotfwhmioscript(sigma)
cdata(:,:)=load(strcat('data/singlinecombinedplotdata',num2str(sigma,'%5.3f'),'3.0secint.txt'));
cfwhm=cdata(:,1);
thetamax=cdata(:,2);
width=thetatowidth(thetamax);
cmaxval=cdata(:,3);
pdata(:,:)=load(strcat('data/singlineproponlyplotdata',num2str(sigma,'%5.3f'),'3.0secint.txt'));
pf... |
function [AVGTeam1,AVGTeam2] = MOD_FirstIn(PROBTeam1,PROBTeam2)
%AVGTeam1 and AVGTeam2 are the average of the first dragons for every team
%PROBTeam1 and PROBTEAM" are the probability of every team of doing
%the first something.
AVGTeam1=PROBTeam1/(PROBTeam1+PROBTeam2);
AVGTeam2=1-AVGTeam1;
end
|
%%% ELEN3024 Lab 1 - Exercise 1b
%{
Tyson Cross 1239448
Jason Parry 1046955
Rashaad Cassim 1099797
%}
clc; clear all; set(0,'ShowHiddenHandles','on'); delete(get(0,'Children'));
interactive = 0;
export_on = 0;
%% Input
if (interactive)
prompt = 'Enter a value for message signal amplitude: ';
A_m ... |
function [ws,wsx] = stationarysol(x,y)
global a b nu
epsn = 0.6;
c = atan(1/(1 + epsn)) - pi*(1+epsn)/4;
%epsn=0.323745909529;
%c=-pi/8;
fun = @(x) -0.5*nu*pi*(1+epsn)*tan(0.25*pi*(1+epsn)*x/a + c);
g = sin(pi*y/b);
ws = fun(x) .* g;
wsx= imag(fun(x+1i*eps))/eps .* g;
%us = ws(1);
%gs = -nu*pi/2*(1+epsn)*sec(pi*... |
function [ uu ] = interpnfft(x,u,xx,dim)
% Interpolation from u(x) to uu(xx)
if nargin<4
[~,dim]=max(size(u)>1);
end
% Non-equispaced FFT
x=x(:); n=length(x); N=2*n-2;
xx=xx(:); m=length(xx); M=2*m-2;
% Retrieve coefficients: adjoint transform N -> N
plan1=nfft(1,N,N);
plan1.x=[acos(x(1:end)); -acos(x(end-1:-1... |
function [] = CheckSamplesOneNyOne()
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
Variables=evalin('base','whos(''Set_*'')');
Variables=Variables(strcmp({Variables.class},'PitsSample'));
Variables={Variables.name};
if isempty(Variables)
warning('No sample found.')
return;
end
... |
function h = discharge_charge_hess(x, lam, mpc)
ns = mpc.nstorage;
ng = mpc.ngenerators;
N = mpc.horizon;
%Here we are provided with variables x using the internal ordering
%reorder the variables back so that we can compute the offsets
%for the flexibility variables ourselves.
%We assume ordering as defined in add_st... |
disp('Escolher som Auralizado');
[filename,path]=uigetfile({'*.wav'},'Escolher Som Auralizado','MultiSelect', 'on');
[somA,fsA]=wavread(filename);
somAR=somA/2,4;
sound(somA, fsA);
sound(somAR, fsA);
wavwrite(somAR,fsA, ['InEar' filename]); |
function [T,I,Y]=naivePerfusionResponsepotentP2X4(ton,toff,Ttot)
ode=modelODEpotentP2X4(ton,toff);
naive=zeros(37,1);
naive(1)=1;
setAuxiliarypotentP2X4(naive);
[T,Y]=ode15s(ode,[0 Ttot],naive,odeset('NonNegative',1:37));
I=getTotalCurrentpotentP2X4(Y);
end |
function a = allocator(unit, type)
% unit: 'gpu' or 'cpu'
% type: data type ('single', 'double', etc.)
if nargin < 2, type = 'single'; end
if unit == 'gpu'
g = gpuDevice;
a.free = @() g.FreeMemory;
a.reset = @() reset(gpuDevice);
a.on = @(x) gpuArray(x);
a.off = @(x) gather(x);
a.zeros = @(sz) gpu... |
load CCCP
data = CCCP(:,1:4);
label_true = CCCP(:,5);
clear CCCP |
close all
clear all
try
%% Load Screens
Screen('Preference', 'SkipSyncTests', 1);
[window, rect] = Screen('OpenWindow', 0,[]);
Screen('BlendFunction', window, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); % allowing transparency in the photos
HideCursor();
window_w = rect(3); % defining size of screen
window_h = rect(4);
c... |
function dist_in_km = lat_long_to_km(lat,lon)
nb_pt = numel(lat);
if isrow(lat)
lat=lat';
end
if isrow(lon)
lon=lon';
end
try
dist_in_deg = distance([lat(1:nb_pt-1) lon(1:nb_pt-1)],[lat(2:nb_pt) lon(2:nb_pt)]);
dist_in_km = deg2km(dist_in_deg);
dist_in_km=dist_in_km';
catch err
print_errors... |
function S_structdata = structdata_getGeneralProperties(data_id,data_type,S_setupdata,calc_times,psteps)
S_structdata.id = data_id;
S_structdata.type = data_type;
S_structdata.pump = S_setupdata.pump(psteps);
S_structdata.k_a = S_setupdata.k_a;
S_structdata.n ... |
videoReader_R = VideoReader('subject1/proefpersoon 1.1_R.avi');
% Get a video frame with the tongue out to the left.
out_left = read(videoReader_R,500);
out_left_grey = rgb2gray(out_left);
figure, imshow(out_left);
%% Cluster colours within the face box.
% Rough box for face for testing purposes - can replace with pr... |
clear all ;clc;
curdir = pwd;
addpath(genpath(curdir));
% random seed
s = RandStream('mt19937ar','Seed',1);
RandStream.setGlobalStream(s);
% load true model
load marmousi.mat
n = size(v);
v = v(1:300,1:1000);
% construct cells of different models
C = mat2cell(v,[100 100 100],[100 100 100 100 100 100 100 100 100 100])... |
function [ a ] = Tau( N )
% La fonction "Tau(N)" renvoie la matrice des coefficients
% ak par la méthode Tau pour k_max = N .
D=matrice_derivee2(N)+matrice_derivee(N)-2*eye(N+1);
C=CF(N);
F=D(1:N-1,:);
H=[F;C];
J=zeros(N+1,1); J(1)=-2;
a=H\J;
end |
function [Tree,Parent,Kept,ic] = build_hierarchical_tree(H,B,para)
%% This function apply the voting cut on the given bipartite graph
% Input:
% H - the incident matrix of the bipartite graph, a m x n binary matrix;
% B - the weighted adjacency matrix, for spectral clustering on superpixels
% para - the paremeter ... |
function [xji, k] = CalcMidpoints (v, xA, ivar)
% calculates the midpoints between point of interest and all other cell
% nodes projected onto the ivar-th axis
% (equation 19 of Sambridge 1999 I)
% ivar = variable (axis) index
[Npts, Nvars] = size(v);
% find nearest cell node by minimizing distance between v and xA
... |
classdef multivariateTimeSeries < handle
%multivariateTimeSeries Summary of this class goes here
% Detailed explanation goes here
properties (Access = private )
tsInColumns = [] ;
end
properties (Access = public)
labelsOfTimeSeries = [];
unitsOfMeasurement = [];
en... |
function [fullpath] = safepath(varargin)
%SAFEPATH Never overwrite a filename
% Appends the lowest unused integer to the end if necessary
fullpath = fullfile(varargin{:});
if ~exist(fullpath,'file')
return
end
[path,name,ext] = fileparts(fullpath);
i = 0;
while true
test = fullfile(path,[name num2str(i) ext])... |
function y = pSharpe(r, rf)
% 计算sharpe比率
% 输入:
% r: 个券日收益率[m×n],n=20,120,250,500
% rf: 无风险利率[1×1],输入参数为一年期定存利率
% 输出:
% y: Sharpe比率[m×1]
% 将年无风险利率转化成日无风险利率
rf = rf/250;
[m,n]=size(r);
rf=rf*ones(m,n);
y=zeros(m,1);
% 计算个券的波动率
std_r = std(r,0,2);
i=find(std_r==0);
y(i)=NaN;
i=find(std_r~=0);
if ~isempty(i)
y(i) = (... |
function [nlp, rbm] = CheckFeasibility(nlp, rbm, data)
if ~all(all(rbm.States.q.LowerBound < data.q))
warning('Initial guess: seed.q < q.LB')
end
if ~all(all(rbm.States.q.UpperBound > data.q))
warning('Initial guess: seed.q > q.UB')
end
rbm.States.q.Seed = data.q;
if ~all(all(rbm.States.dq.LowerBound < data.... |
dft = csvread('dft.csv',1,3);
fft = csvread('fft.csv',1,3);
fft_comb = csvread('fft_comb.csv',1,3);
dft_par = csvread('dft_par.csv',1,3);
fft_opt = csvread('fft_opt.csv',1,3);
fft_parfor = csvread('fft_parfor.csv',1,3);
fft_tg = csvread('fft_tg.csv',1,3);
n = min(length(fft),min(length(fft_comb),min(length(fft_opt),mi... |
function y = at(t,h)
y = (vt(t+h)-vt(t-h))./(2.*h);
end |
function logProb = lm_prob(sentence, LM, type, delta, vocabSize)
%
% lm_prob
%
% This function computes the LOG probability of a sentence, given a
% language model and whether or not to apply add-delta smoothing
%
% INPUTS:
%
% sentence : (string) The sentence whose probability we wish
% ... |
function newY = updateY2(Y,C,W,E,m,n,N,eta,rho,D,Omega)
d = m*n;
newY = zeros(d,N);
I = eye(N); T = Y-rho*eta*Y*(I-C)*(I-C)';
for p = 1:N
newY(:,p) = T(:,p);
for q = 1:d
%newY(:,p) = newY(:,p)+eta*Q{q}'*D*(W{p,q}-Q{q}*Y(:,p))-eta*Q{q}'*E{p,q};
e = zeros(2,1);
if mod(q,m)~=0; e(1) = Y(q... |
function [err,alpha] = Aufgabe_5_2_f()
% Beschreibung der Variablen
% Eingabe: nicht vorhanden
% Ausgabe:
% err: Vektor, err(i) enthaelt den Fehler zur Schrittweite h_i
% alpha: Vektor, alpha(i) enthaelt die Konvergenzordnung, die sich
% aus err(i) und err(i+1) ergibt
a = 0;
b = 3;
h = [1/2, 1/4, 1/8, 1/16, ... |
% log likelihood ratio function
% April 23, 2013, add constraints for maximizing the likelihood ratio
function [LLR,varargout]=LogLikelihoodRatio(x,inParams)
%function LLR=LogLikelihoodRatio(x,inParams)
xmaxmin = inParams.xmaxmin;
%global Np alphaP deltaP kp N timingResiduals sd yr
%global variables defined in the si... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.