text stringlengths 8 6.12M |
|---|
function [] = qtb_plot()
global qtb_statistic;
std_line_width = 1;
line_width = 2;
font_size = 12;
filling_alpha = 0.1;
color = 'b';
iters = qtb_statistic.iterations;
n = length(iters);
len = cellfun(@length, qtb_statistic.fidelity);
figure();
if a... |
close all; clear all; clc;
load ('all_data.mat');
normal_all = featureNormalize(all_data);
dupl_data = featureNormalize(all_data);
random_noise = -0.02 + 0.04 * rand(size(dupl_data));
%%
idx = randperm(50,50);
train_idx = idx(1:30);
cv_idx = idx(31:40);
test_idx = idx(41:50);
train = zeros(30, 12);
cv = ze... |
function [d,n] = ridders(f, a, b, tol)
% RIDDERS' root finding method. A quadratically convergent
% bracketing method
%
% d = RIDDERS(f, a, b, tol) solve f(d) == 0 for d in (a,b)
% to a relavtive tolerence of tol
fa = f(a);
fb = f(b);
if fa*fb > 0
error(['ridders: functi... |
% load data
load sampledata2;
% prob 2
num_cancer = sum(data(:, 3))
num_drink_6plus = sum(data(:, 2)>5)
num_50plus = sum(data(:,1)>50)
num_20minus = sum(data(:, 1)<20)
% prob 3
cancer_indices = find(data(:, 3) == 1.0);
histogram(data(cancer_indices, 1), [15, 25, 35, 45, 55, 65, 75]);
% prob 4
nocancer_indices = find... |
function [ L,S] = UpdateS(Ag,A,W,L,betag,UWXXWU,UWXGXGWU,param)
[l,k] = size(L);
manifold = elliptopefactory(l,k);
problem.M = manifold;
% Define the problem cost function and its gradient.
problem.cost = @(x) LCost(Ag,A,W,x, betag, UWXXWU,UWXGXGWU,param);
problem.grad = @(x) LGrad(... |
% demo_plotMultiLevelTree.m
% demo script for custom function plotMultiLevelTree.m
% 12/11/2018 JHB
%% initialize
clear all;
%% generate example
nodenames = {'A11';'A12';'A13';'A21';'A22';'B11';'B12';'B21';'B22'};
g1 = 1:9; % original nodes
g2 = [1 1 1 2 2 3 3 4 4];
g3 = [1 1 1 1 1 2 2 2 2];
gall = [g1(:) g2(:) ... |
load('npfda_pho_norm.mat');
% Normalization
x_timegrid = phoX';
sample_mean = mean(mean(phoY));
sample_std = 2*std(phoY(:));
phoY = phoY - sample_mean;
phoY = phoY / sample_std;
data = phoY;
global gt_labels;
[~,gt_labels] = find(phoZ);
hyper = make_hyper();
G0 = nhgpprior(x_timegrid, ...
... |
function my_cameralist_function(src,event,data)
% Callback function for "List of Added Cameras" (eh2_camera_visu)
% Resume - respond to uiwait in while loop
uiresume(data.f)
% Load file of added cameras
matfile = load('added_camera.mat');
camdata = matfile.cam;
s = size(camdata);
n = s(1);
for i = 1:n... |
% this script produces figure 6 of the article
% plot error vs correlation summary
jitterIndex = 4;
figure(1), plotCorr('data_correlation.mat', jitterIndex)
set(gcf, 'Position', [360 669 308 265])
% plot examples ...
clear all
rand('state',0)
signal = load('signals_figure2.mat')
dt = .0002;
nStats = 20;
n = 500;... |
function [ backs ] = prueba2( )
close all;
v = VideoReader('Barcelona.mp4');
h = v.Height;
w = v.Width;
%M = read(v);
%[n m d N] = size(backs);
function [v] = calcvec(im)
[c1, x1] = imhist(im(:,:,1));
[c2, x1] = imhist(im(:,:,2));
[c3, x1] = imhist(im(:,:,3));
v = cat(1,c1, c2, c3)... |
function [X, y] = make_blobs(n_samples, centers, cluster_std, center_box, shuffle, random_state)
% Generate isotropic Gaussian blobs for clustering in 2D.
% A simple toy dataset to visualize clustering and classification
% algorithms.
if nargin == 2
cluster_std = 1.0;
center_box = [-10, 10];
shuffle = true;... |
function [polyPre,polyForm,polyPost]=polyDef()
polyPre = [0, 4, 8, 0, ...
0, 6, 13, 2, 0, 1, ...
0, 6, 14, 2, 0, 0];
polyForm = [0, 44, 16, 3];
polyPost = [0, 4, 17, 0];
str=dec2hex(polyPre,2);
str=str';
str=str(:);
polyPres(1,:)=str(1:8)';
polyPres(2,:)=str(9:16)';
polyPres(3,:)=str(17:24)';
polyPres(4,:... |
%% Import mode activity for Ti project (basal, prism, 1st order pyr)
function [activity,a_prism,a_basal,a_pyr]= importACT_TiIso(pname,phaseID)
%read raw text
data = importdata([pname '\ACT_PH' num2str(phaseID) '.OUT']);
%parse out the bit we want
activity = data.data(:,3:5);
% separate into separate slip systems
a_... |
N=1000;
x= linspace(0,1,N+1);
dx= x(2)-x(1);
u=exp(-(x-0.5).^2/0.1^2);
u0=u(2:end-1);
global k A b
A=eye(N-1);
A=A*(-2/dx^2);
A=A+1/dx^2 * diag(ones(N-2,1),-1);
A=A+1/dx^2 * diag(ones(N-2,1),1);
b=zeros(N-1,1);
k=0.01;
[t,u]=ode45(@ddt_heat,[0,1],u0);
t=x(2:end-1);
test=u(1,:);
for i=1:250:size(u,1)
y=u(i,:)... |
function [vals derivs] = a_amphoteric3(flag,fd,in)
% 3 multivalent traps
% input energies are wrt Ev
%
gp=1;
g0=2;
gm=1;
if strcmp(flag,'eq') || strcmp(flag,'eqvals')
po=in.p;
no=in.n;
eg=in.eg;
nv=in.nv;
nc=in.nc;
nt=in.nt3;
esp_v=in.e3p+log(gp/g0);
esm_v=in.e3... |
function [Psychometric] = Get_Psychometric (s,initialVars,analysisVars)
load('AS_CESS.mat')
[~, nfmodels, ~, ~] = destructure_initial_variables(initialVars);
[partners,n_partners,~, ~] = destructure_analysis_variables(analysisVars);
n_models = nfmodels;
Psychometric = cell(n_partners,1);
for p = 1:n_partners
... |
function compile_indirect(flags, common_abip)
% compile indirect
if (flags.COMPILE_WITH_OPENMP)
cmd = sprintf('mex -O %s %s %s %s COMPFLAGS="/openmp \\$COMPFLAGS" CFLAGS="\\$CFLAGS -fopenmp" abip/linsys/indirect/private.c %s -Iabip -Iabip/include -Iabip/linsys %s %s %s -output abip_indirect', flags.arr, flags.LCF... |
% agglomDemo
% Based on http://www.mathworks.com/access/helpdesk/help/toolbox/stats/index.html
if 0 % Alpaydin data
X = [1 3;
1 4;
5 2;
5 1;
2 2;
7 2];
end
X = [1 2;2.5 4.5;2 2;4 1.5;4 2.5]
figure;clf
axis on
grid on
N = size(X,1);
for i=1:N
hold on
h=text(X(i,1)-0.1, X(i,2), sprintf('%... |
%Simulando a recarga da bateria LIR18650 2600mAh (vide datasheet em ../docs/)
%version: 2010a ou 2017a
function simulate_battery(version)
disp('Reminding: Please be sure that the workspace is clean (use clear all)');
NTX = 1;
W = 3769.911; %600Hz
R = [0.7 0.7]'; %resistência fixa dos RLCs (default)
C = [-1 ... |
%% Load c_frost results
%sol = loadjson(fullfile(local_output_path,'output.json'));
file_name = fullfile(local_output_path,'sol.json');
[gait, sol, info] = two_step.utils.load_result(nlp, file_name);
% checkConstraints(nlp, sol, 1e-4, 'log.txt')
%% Animate
% set 'SkipExporting' option to false for the first time to a... |
% Copyright 2019, by the California Institute of Technology. ALL RIGHTS
% RESERVED. United States Government Sponsorship acknowledged. Any
% commercial use must be negotiated with the Office of Technology Transfer
% at the California Institute of Technology.
% -----------------------------------------------------------... |
function [x,flag,relres,iter] = pcg_mod2(A,b,tol,maxit,M1,M2,x0,varargin)
m = size(b,1);
n = m;
% Check for all zero right hand side vector => all zero solution
n2b = norm(b); % Norm of rhs vector, b
if (n2b == 0) % if rhs vector is all zeros
x = zeros(n,1); ... |
function [ im1_pts, im2_pts ] = click_correspondences( im1, im2 )
[im1_pts, im2_pts] = cpselect(im1, im2, 'Wait', true);
% ADD CORNERS so that every pixel is within a triangle
im1_pts(end+1, :) = [0 0];
im1_pts(end+1, :) = [size(im1,2) 0];
im1_pts(end+1, :) = [size(im1,2) size(im1,1)];
im1_pts(end+1, :) = [0 size(im1... |
function [ net_en_out ] = fun_kfold_mod_train(all_data_in,all_data_out,...
add_data_in,add_data_out,...
n_kfold,nnt_epochs_en,er_thred,n_atom)
%% mod k-fold to train ann
% the add data are always in train set
%% main part
% ... |
function [X, delta, G] = ch_gpsls(X, SVP, rho)
% GPS 伪距最小二乘法求解, 状态量为 X Y Z B(钟差)
% X: X 值(1:3) 位置delta, (4) 用户钟差偏差
% rho: 校正后的伪距
% SVP: 卫星位置矩阵
% delta: delta 值(1:3) 位置delta, (4) 用户钟差偏差
B1=1;
END_LOOP=100;
%卫星个数
n = size(SVP, 2);
if n < 4
delta = 0;
G = 0;
return
end
X0 = X;
for loop = 1:10
... |
function m = generate_rotmatrix_drvd(r, b, s, derived_by)
% Patrucco, 2021
% Generate derivated form of the rotation matrix (euler angles, s-r-b
% sequence). "derived_by" equals 1 for r, 2 for b, 3 for s
% Lc11 = cos(s)*cos(b) - sin(b)*sin(s)*sin(r)
dLc11_dr = -sin(b)*sin(s)*cos(r);
dLc11_db = -cos(s)*sin(b) - cos(b)*... |
function IAPSsurvey(subid)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %
% IAPS PATTERN EXPRESSION POST SCAN SURVEY %
% WagerLab: Luke & Marianne 2014 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %
%% paths
% addpath(genpath('/Applications/Psychtoolbox'));
% add... |
function [ RB_space ] = Greedy( TS, tol)
%Perform greedy algorithm (using IMGS) to form a reduced basis from a given training set.
%Inputs TS (a ndarray containing a set of normalised training vectors), wt
%(a weight, or vector of weights, for normalisation), and tol (a stopping
%criterion for the algorithm).
... |
function p = trialSetup(p)
%pds.behavior.reward.trialSetup(p) allocate memory for use during the trial
p.trial.behavior.reward.iReward = 1; % counter for reward times
p.trial.behavior.reward.timeReward = nan(2, ceil(p.trial.pldaps.maxTrialLength*2)); %preallocate for a reward up to every 0.5 s |
% Initial version of the code was adopted from Zakaria et al.
% https://sites.google.com/site/icdmclusteringts/
function [gap, ma, mb, sa, sb, r] = ComputeGapOne(dis, d)
ma = 0; mb = 0; sa = 0; sb = 0;
Da = find(dis <= d);
Db = find(dis > d);
gap = 0;
r = 0;
if (length(Da)<2 || length(Db)<2)
... |
function b=imtocol(varargin)
%IM2COL Rearrange image blocks into columns.
% B = IMTOCOL(A,[M N],'distinct') rearranges each distinct
% M-by-N block in the image A into a column of B. IM2COL pads A
% with zeros, if necessary, so its size is an integer multiple
% of M-by-N. If A = [A11 A12; A21 A22], where each A... |
function theta = Roll_Theta(t,nu)
% Roll up a vector of theta values into a matrix if theres only 2 layers and
% into a cell array of matrices if there are more than 2 layers
% The minimum is 2 layers (input, output);
nl = size(nu,1); % Number of layers
if nl>2
% There are multiple thetas, use a ... |
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
clc;clear;close all;format shortg
addpath([pwd,'/utility/'])
problemnames={'Full XOR','Partial XOR','Twisted XOR','Partial Twisted'};
coordinates=load('physcoords_7x7.txt... |
clear;
van_coe=73.07/100;
volume_ratio=.5;
fai=volume_ratio;
f_f=.01:.01:.99;
f_d=.01:.01:.99;
c_d0=35;
c_f0=.1;
%o_p_power=.5*niu*R*T*(c_d0-c_f0)/10^5;
%o_p_power=0.5*van_coe*(c_d0-c_f0);
%o_p_energy=van_coe*((1-volume_ratio)*c_d0-volume_ratio*c_f0+(2*volume_ratio-1)*sqrt(c_d0*c_f0));
%max_deltaP1=2*o_p_power;
%delt... |
function [all_ob_heights] = make_obj_height_map(results_mat_name, obj_indices)
load(strcat(strcat('../../results_ALL/', results_mat_name), ''));
if (obj_indices==0)
obj_nums = 1:length(A)-1;
else
obj_nums=obj_indices;
end
for obj_num=obj_nums
disp(['computing heights obj ' num2str(obj_num) ' of ' num2str(length(o... |
% Patrascoiu Ion - Radu, 312 CD
function [NC points] = read_input_data(file_params, file_points)
NC = 0;
points = [];
NC = load(file_params);
load(file_points);
endfunction |
close all;
clear all;
directory = './pages'
page_paths = dir([directory '/*.jpg']);
correct_extractions = [];
incorrect_extractions = [];
for i = 1 : length(page_paths)
path = [directory '/' page_paths(i).name];
page = imread(path);
corrected = correct_perspective(page);
close all;
imshow(page);
figure... |
numberOfModules=10;
modules=1:numberOfModules;
power_rating=modules;
power_rating_single_fault =(modules(1:end-1)/modules(2:end)).^2.*power_rating(2:end);
% plot(modules,power_rating);
figure1=figure();
yyaxis left
plot(modules(2:end),power_rating_single_fault,'LineStyle','-','Marker','x', ...
'MarkerSize',10,... |
function samples = load_samples(file, format = 'binary')
fd = fopen(file, 'r');
samples_struct = [];
tmp_str = [];
if strcmp(tolower(format), 'text')
while (1)
tmp_str = fgetl(fd);
if (tmp_str == -1)
break;
end
sample... |
N_test=1;
for i=1:N_test
for N_init=50:50:1000
[n,fc,vel]=Simulation_Gravity_1D(N_init);
save([num2str(i),'-',num2str(n)],'n','fc','vel')
end
end |
% test lbp with boost in monkey detection
% function testLBPBoost
clear;close all;clc;
addpath(genpath('C:\zxk\Research\zz_fdtool_release'));
% posPath = 'C:\zxk\Research\monkeyData\Camera4_labeledVideos_Patch_Pos';
% negPath = 'C:\zxk\Research\monkeyData\Camera4_labeledVideos_Patch_Neg3';
% posFiles = dir([posPath... |
clc;
clear all;
close all;
%%MATLAB Codes to Calculate the Optical Power Distribution of LOS Link at Receiving Plane for a Typical Room
theta =70;
% Noise-bandwidth factor %
I2 = 0.562;
% Data rate (Bit per second)
Rb = 115200;
% Ambient light power (Ampere) %
Iamb = 7E-8;
% Photodiode responsivity (A/W )%
... |
% plot for SI
% WTJ, 20190823
%% Individual point plot
load('./OE_SGS_FSW_data/RedRun01/MWFreqSweep_20190822T222655.mat');
data = fsw_data_all{10};
hf = figure;
hf.Position = [680 603 1241 467];
subplot(121);
xlim([-25, 25]);
ylim([-165, -120]);
x_range = 2*[-fswconfig.rbw, fswconfig.rbw];
ys = ylim; y1 = min(ys); y2... |
% 输 入 格 式 举 例: [ ste_cover, len_total ] = randlsbhide ( '9999.jpg' ,'test.txt' , '9999testrand.bmp' ,2001)
% 参数说明:
% input 是信息隐蔽载体图像
% file 是秘密消息文件
% output 是信息隐秘后的生成图像
% key 是随机间隔函数的密钥
function [ ste_cover, len_total] = randlsbhide( input, file, output, key) % 读入图像矩阵
cover = imread( input) ;
ste_cover = cover;
ste_c... |
function [estx] = mamodelgenerator(x)
sizeOfX = size(x);
[thetas, min] = thetaestimator(x,1);
theta21 = thetas(1); %Pongo cada theta en una variable con su subindice en el nombre
theta22 = thetas(2);
varN = min/(sizeOfX(2) - 2); %Calculo la varianza de e(n) por fórmula (pág 603)
wgn = sqrt(varN)*randn([1,4096]); %... |
function pepformula = pepformula(pepstring)
%PEPFORMULA: Compute chemical formula of a peptide
%
% Syntax:
% pepformula = pepformula(pepseq)
%
% Input:
% pepseq: a string containing the peptide sequence
%
% Output:
% pepformula: an object of MATLAB Chemformula class
% representing peptide chemical form... |
%{
Define as many paramaters as you want in this file. Then call
paraminclude(<filename>) to add the params struct to the function
%}
params = struct(...
'freqs',[0:200], ...
'maxFreq', 200, ...
'method','periodogram', ...
'nMultitapers',4, ...
'subtractReference', true, ...
'subtractB... |
function positionVehicle = ConvertGlobalToVehicle(positionGlobal, qx, qy, theta)
T = [cos(theta) -sin(theta) qx; sin(theta) cos(theta) qy; 0 0 1];
pxy = [positionGlobal;1];
puv = inv(T) * pxy;
positionVehicle = puv(1:2);
end
|
axis([-2 1 -1 2])
axis equal
subplot(3,2,1);
plot(t0,x0(1:5,:));
title('Initial linear guess')
subplot(3,2,2);
plot(t,xf(1:5,:));
title('Optimized')
subplot(3,2,3);
plot(t0,x0(6:10,:));
subplot(3,2,4);
plot(t,xf(6:10,:));
subplot(3,2,5);
plot(t0,x0(11:15,:));
subplot(3,2,6);
plot(t,xf(11:15,:));
% r0... |
function [s_interf_est, g_interf_est] = FIBD(d_interf, T, n, tau, tol, obs, empty_source, mirror_brdf, num_lin, margin)
% Initial guesses
s_interf_est = zeros(2*T-1, tau);
s_interf_est(T) = 1;
g_interf_est = rand(2*tau-1, n*n);
% for i = 1:n
% for j = 1:n
% index = get_... |
%main_Logistic.m
close all
clear;
clc;
global data
k0 = 17.5; %initial k
r0 = 0.7; %initial r
x0 = 0.1; %initial x
theta=[k0,r0];
% Generates "simulted" data.
n = 100;
t0 = 0;
tf = 25;
t = 0: tf/n : tf;
nl = 0.05; %level of noise
[t,x] = ode45(@LogisticModel,t,x0,[],theta);
d=x(:,1);
noise = nl*r... |
function [M_k, norm1] = M_sort(H_k, D, D_len, Mr)
% 排序求出每个用户的W矩阵
% D 码本
% D_len 码本大小
% norm1 存储每个d * H的范数和序号(按phase排序的)
%%
dH_norm = zeros(2,D_len); % 存储每个d * H的范数和序号
for i = 1 : D_len
A = D(:, i)' * H_k;
dH_norm(1, i) = norm(A,'fro');
end
dH_norm(2, :) = (1 : D_len);
norm1 = dH_norm(1, :);
% 排序(冒泡排序, 降序)
f... |
function Q = rota1001fill(A10, A01, bgval)
%------------------------------------------------------------------------------
%
% The quincunx grid as constituted by A10 and A01 is rotated and mapped
% onto a rectangular grid together with the corresponding values.
% The excess area is filled by padding with value bgval i... |
%% Safae OUAJIH
clear; % Efface les variables de l'environnement de travail
close all; % Ferme les figures ouvertes
clc; % Efface la console
%% Initialisation des parametres
fe = 1e4; % Fréquence d’échantillonnage
Te = 1/fe; % Période d’échantillonnage
Ns=5000; % nombre de symboles par paq... |
sclassdef testcashier < matlab.uitest.TestCase
properties
login
end
methods (TestMethodSetup)
function launchApp(testCase)
testCase.login = Login;
testCase.addTeardown(@delete,testCase.login);
end
end
methods(Test)
function test_cashier(testC... |
function sim_options = ui_read_options
% packet lengths vector, in bits
pkt_length = eval(get(findobj('Tag', 'PktLen'),'String'))*8;
% convolutional code options
conv_code_rate = get(findobj('Tag', 'ConvCodeRate'),'String');
conv_code_rate = conv_code_rate(get(findobj('Tag', 'ConvCodeRate'),'Value'),:);
% Interleavi... |
function value= ECAT_readHeaderInt2(subHeader, byteN);
%
% Reads the Nth byte (byteN) in ECAT header/subHeader and converts it to a
% int2 value.
%
% function double= ECAT_readHeaderInt2( subHeader, byteN);
%
% Example 1, read X_DIMENSION from image file subheader (ECAT 7)
% y= ECAT_readHeaderInt2(subHeader... |
%Steven Kolln
%Don't forget to add the voicebox folder to the classpath
%For the function [ceps,freqresp,fb,fbrecon,freqrecon] = mfcc(audioData,12000,100);
%The parameters passed to the mfcc.m are as follow: ceps cepstrum coefficients,
%freqresp fast fourier transform, fb converts to Mel-frequency sca... |
function names = GetFeatureNames( self )
% returns feature names for display
nF = length(self.Features);
names = cell(nF,1);
for iF = 1:nF
names{iF} = self.Features{iF}.name;
end
end
|
function [transformMatrix] = Get_Position()
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
% Joint Torque Vector,
%
% %Joint Angle Acceleration Vector 3x1
% %Mass maxtrix is 3x3
% %Coriolis/Centripital Coupling Vector 3x1
% %Graity term 3x1
%
% To get the point masses at the cente... |
%%
rm=measbpmresp('Model');
figure(1)
surf(rm)
figure(2)
contour(rm)
%%
rmx=rm(1:88, 1:88);
rmy=rm(89:176, 89:176);
irmx=inv(rmx);
irmy=inv(rmy);
%%
figure(2)
subplot(2,2,1)
surfc(rmx)
xaxis([0 88])
yaxis([0 88])
subplot(2,2,2)
surfc(irmx)
xaxis([0 88])
yaxis([0 88])
subplot(2,2,3)
surfc(rmy)
xaxis([0 88])
yaxis([0 88]... |
function [ imgDCT ] = myDCT(img, bd, coeffs)
%MYDCT(img, bd, coeffs) implements the DCT transform and reconstruct the
%image using a limited number of coefficients.
% myDCT exploits the built-in blockproc and dctmtx to compute the DCT
% transform of img, that is then reconstructed masking the result of the
% tr... |
function PM_tool(varargin);
% function PM_tool(varargin);
% Function for point measurements on a set of images.
% Use with imagesc or imagescn.
%
% Usage: PM_tool;
%
% Author: Daniel Herzka herzkad@nih.gov
% Laboratory of Cardiac Energetics
% National Heart, Lung and Blood Institute, NIH, DHHS
% Bethesda,... |
function [modelData] = jensen_params(modelData)
%JENSENPARAMS Summary of this function goes here
% Detailed explanation goes here
modelData.Ke = 0.05; % wake expansion parameters
modelData.KeCorrCT = 0.0; % CT-correction factor
modelData.baselineCT = 4.0*(1.0/3.0)*(1.0-(1.0/3.0)); % Baseline CT fo... |
N = 1000; sp = 0.1; thr = 0.1; [w1,w2] = deal(zeros(N,1));
rng(42);
% reset flags
[doOnline,plotTrial,doOverlap,doStructured,doBanded,doDecorr] = deal(false);
dt = 0.005;
tau = 0.1;
time = dt:dt:120;
tOn = 2.5;
tOff = 4.5;
stimRaw = double(time>tOn & time<tOff);
stim1 = smoothts(stimRaw,'e',4/d... |
function out = num2strBatch(num)
out = cell(1,length(num));
for i = 1:length(num)
out{i} = num2str(num(i));
end |
function T = quat2dcm(q)
%
% T = quat2dcm(q)
% Give the rotation matrix corresponding to the input quaternion.
% Input q is a quaternion i.e. a nx4 array.
% To rotate a basis, post multiply by T.
% To transform a vector sensor measurement, pre-multiply by T'.
%
% Anne Piemont
% Created 13 Aug 2013
% Las... |
function [ w, theta ] = AxisAng3( r )
% Usage
% Input - r = exponential coordinates for rotation r = w*theta
% Output - The unit vector w and the theta
%Example
% Input - r = [pi/4, 0, 0]
% Output [w, theta] = [1,0,0]' and 0.784
w = [];
theta = [];
if(size(r,2) > 1) %Make it a column vector if a row vector
r = ... |
%%%%%%%%%%%%%%%% PLOT SNAKE BOUNDARIES %%%%%%%%%%%%%%%%
% Plots the extracted convex hulls on an image and saves the images in a
% directory in the 'savePath'.
% Inputs:
% plotS - sets the background image
% options: 'original' - original image
% 'orig... |
ordering_types = {
'Position', ...
'S. Initial Domain', ...
'S. Constraints', ...
'L. Constraints', ...
'S. Domain First'
};
|
function [ fq ] = problem_F(q,quadpoint,appdata)
% Evaluates f(q) for the given problem
% written by data.Pierson Guthrey
% -------------------------------------------------
% INdata.PUTS q
% OUTdata.PUTS f evaluated for conserved variables f
% Note: other variables may be %loaded in from the problem parameter fil... |
function [bbox, class, prob,contri_x,contri_y,centers_x,centers_y ] = mergeCenters(bbox, class,prob,contri_x,contri_y,centers_x,centers_y )
%Result=struct('min_x',[],'min_y',[],'max_x',[],'max_y',[],'contri_x',{},'contri_y',{},'avg_prob1',[],'per_class_pixels1',[],'avg_prob2',[],'per_class_pixels2',[],'contri_by_tot... |
function szt = TTNSzT(L,w,Jorder)
% Total Sz for TTN
% input: Length (L), Tree tensor network (w), order in which the network is
% built (Jorder)
% output: total Sz (szt)
% Andrew Goldsborough 03/05/2013
% function to calculate the total Sz expectation value
%create SzT MPO
Wz = cell(L,1);
Wz{1} = zeros(2,2,2,2);
Wz... |
function [ classifier ] = weka_classifier( vecTrain, gtTrain, type )
%WEKA_CLASSIFIER Summary of this function goes here
%
% - vecTrain: vector of dimension N by d, containing N features of size d
% - gtTrain: vector of dimension N by 1, containing 1 if the element
% belongs to the class and -1 otherwise
% ... |
classdef PulseTrainNIC3Matlab < FormatNIC3Matlab & PulseTrain
% PulseTrainNIC3Matlab < FormatNIC3Matlab & PulseTrain
%
% Simple pulse train class for Cochlear devices using NIC3/Matlab interface:
% prestimulus -- stimulus -- prestimulus
%
% PulseTrainNIC3Matlab Properties (PulseTrain class... |
% Author: Tanalp Şengün
% Homework 1 on Linear System Theory
%This is the eight question.
clc
clearvars
A= [ 0.01 0.001 ; 0.001 0.01 ];
% this is the matrix A, as discussed in the question.
x0= [ 25 ; 0 ];
% approximation point x0 as defined in the question.
grad_x0= [ 0.5 ; 0.05 ];
%this is the gradient vector c... |
clc;
clear all;
close all;
%%
%Reading Data
Data = dlmread('Sample.txt');
%%
% Simple Example
ST = 6;
L = 10;
M = 25;
W = 1;
Selected_Index = DRLSH(Data,M,L,W,ST);
Selected_Data = Data(Selected_Index,:);
figure,
scatter(Data(:,1), Data(:,2), [], Data(:,3), 'filled')
title('Original Datatset')
... |
% 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,... |
function state = CreateState(state, t, y, P)
global param
st = struct;
st.P = P;
st.t = t;
st.r = y(:, 1);
st.theta = y(:, 2);
st.phi = y(:, 3);
st.V = y(:, 4);
st.gamma = y(:, 5);
st.psi = y(:, 6);
st.S = y(:, 7);
st.sigma ... |
function makeInfo=rtwmakecfg()
%RTWMAKECFG adds include and source directories to rtw make files.
% makeInfo=RTWMAKECFG returns a structured array containing
% following field:
% makeInfo.includePath - cell array containing additional include
% directories. Those directories will be
% ... |
% test errors and correction functions
close all
clear all
addpath('/mntdirect/_machfs/liuzzo/CODE/LatticeTuningFunctions');
addpath('/mntdirect/_machfs/liuzzo/CODE/LatticeTuningFunctions/correction/response matrix')
addpath('/mntdirect/_machfs/liuzzo/CODE/LatticeTuningFunctions/correction/');
addpath('/mntdirect/_mac... |
function obj = lineXML(obj,line)
%lineXML Parsing the XML to the corresponding classes and properties
%
%----------------------------------------------------------------------
% BSD 3-Clause License
%
% Copyright (c) 2020, Jonas Wurst, Alberto Flores Fernández
% All rights reserved.
... |
% Surround matrix with NaNs
function [R]=NanMat(Data,GridSize,varargin)
%Input = Data: a m*n matrix
% GridSize: Optional, only needed if data is entered as a list
% a 1x2 vector of size of original grid. (npx,npy)
%output = R: a m+2*n+2 matrix in which Data is preserved and surrounded by
%NaN's
%R... |
%Plot starting positions
ARSL = plot(Field.RSL.x, Field.RSL.y, 'rx');
ARSM = plot(Field.RSM.x, Field.RSM.y, 'rx');
ARSR = plot(Field.RSR.x, Field.RSR.y, 'rx');
ABSL = plot(Field.BSL.x, Field.BSL.y, 'bx');
ABSM = plot(Field.BSM.x, Field.BSM.y, 'bx');
ABSR = plot(Field.BSR.x, Field.BSR.y, 'bx');
% left corner... |
function [bs_pref,bs_null] = tfcell_get_bs_prefnull(tfcell,bs_reps)
%
%
%
%
%
%
%
%
%
%
%
anchor_indices = tfcell.anchor_indices;
d1 = tfcell.bs_speedmatrix_d1;
d2 = tfcell.bs_speedmatrix_d2;
numspeeds = length(tfcell.speedstested);
bs_pref = nan(bs_reps,numspeeds);
bs_null = nan(bs_reps,numspeeds);
for i = 1:bs_r... |
function [] = init_matlabpool(num_threads)
addpath('../ParforProgMon')
if matlabpool('size') ~= num_threads
my_cluster = parcluster('local');
my_cluster.NumWorkers = num_threads;
saveProfile(my_cluster);
if matlabpool('size') > 0
matlabpool close
en... |
% Script which runs the motilityParametersOverTime given just a directory:
%
% Requires dirB be defined
mainAnalysisDirectory = dirB;
% Obtain main directory structure
mainDirectoryContents = dir(mainAnalysisDirectory); % Obtain all main directory contents
mainDirectoryContents(~[mainDirectoryContents.isdir]) = []; %... |
close all
clear all
clc
%% Philip Mocz (2020), Harvard University
% check output of arepo runs
% parameters
N = 128; % resolution
%snap = 20;
snaps = [0 95];
outpath = '/mnt/tigress/MHD/subcriticalMHD_2020/output/mhd128GB4M10/';
%%
Mach = 10;
boxSize = 1;
dx = boxSize/N;
clim = [-2 2];
Nsim = numel(sna... |
function estParams = velime_mstep_MParams(E_X_posterior, COV_X_posterior, C, const)
% estParams = velime_mstep_MParams(E_X_posterior, COV_X_posterior, C, const)
%
% @ Matt Golub, 2014.
% Velocity feedback is not maintained in E_X, so first we concatenate it
% into E_X for this portion of code only. It might be cleane... |
%the script to solve the collocation method
clear
clc
clear
%first get the expression for alpha = alphaZero(1-xx|y/s|)
%substitute with the theta
%the input parameters
AR = 48/7;
theta1 = pi/5;
theta2 = 2*pi/5;
%should be cbar = xxx*C0, but eliminate during the equation
cbar =7/8;
%angle of attack
alpha1=8*(1-1/4*co... |
function clicker(h,~)
%get(h, 'selectiontype')
% 'normal' for left moue button
% 'alt' for right mouse button
% 'extend' for middle mouse button
% 'open' on double click
get(h, 'currentpoint')
% Current mouse location, in pixels from the lower left.
% When the units of t... |
clear all;
addpath('../lib');
%% lets plot 3 cycles of 50Hz AC voltage
f = 50;
Vm = 10;
phi = 0;
% generate the signal
t = [0:0.0001:3/f];
th = 2*pi*f*t;
v = Vm*sin(th+phi);
%% plot now
plotx{1} = t*1E3; %convert time in ms and create a cell array
ploty{1} = v; % assign v to a cell array
opt.XLabel = 'Time, t (ms)';... |
function [y,x] = f_Heun(f,a,b,yin,N)
% MÉTODO HEUN
h = (b-a)/N;
x = a:h:b;
y(1) = yin;
for i = 1:length(x)-1
k1 = y(i) + h*f(x(i),y(i));
y(i+1) = y(i)+ h*( f(x(i),y(i)) + f(x(i+1),k1) )/2 ;
end
end
|
function [lambda] = lambda_mod_fun(x, breadth_mod, att_l, grad_h_fun, grad_lyap_fun)
lambda = 1 - my_exp_loc_act(breadth_mod, att_l, x);
[N, M] = size(x);
% For now
% for m=1:M
% gamma_cond = (grad_h_fun(x(:,m))'*grad_lyap_fun(x(:,m)))/(norm(grad_h_fun(x(:,m)))*norm(grad_lyap_fun(x(:,m))));
% if gamma_cond <... |
% This script analyzes outputs of Rewards Only Multiplex simulations.
% Specifically, it calculates DIVERSITY, PERSISTENCE, ABUNDANCE, and final
% FLOWS (including consumption, production, and metabolic loss) for the
% community and each guild of species at the end of simulations.
% It generates a single file: Results... |
clear
% Generarea unei celule goale de dimensiunea 2x2
Q=cell(2,2)
% Incarcarea celulei
Q={ones(3), [1 3 6 7 6]; ['TN ';'SL ';'DMI';'NDD'], logical(eye(3))};
% Afisarea informatiilor aferente celulei
whos Q
% Afisarea continutului inregei celule i a unui element a acesteia
disp('Afisarea intrege... |
function [c1 c2 c3 x ]=imptext
y=urlread('http://dalab.ee.duth.gr/~296/feed.html');
c1=0;
c2=0;
c3=0;
for i=1:length(y)
if(y(i)=='T')&&(y(i+1)=='i')&&(y(i+2)=='m')
x(i)=y(i);
x(i+1)=y(i+1);
x(i+2)=y(i+2);
x(i+3)=y(i+3);
c1=c1+1;
end
if(y(i)=='F')&&(y(i+1)=='o')&&(y(i+2)=='r')
x(i)=y(i);
x(i+1)=y(i+1);
x(i+2)=y(i+2... |
function [A] = specialMatrix(n,m)
% This function should return a matrix A as described in the problem statement
% Inputs n is the number of rows, and m the number of columns
% It is recomended to first create the matrxix A of the correct size, filling it with zeros to start with is not a bad choice
if nargin ~= 2
... |
function [grad]= B_hadamard(input_layers, curr_layer, future_layers)
input = input_layers{1}.a;
mask = input_layers{2}.a;
future_grad = GetFutureGrad(future_layers, curr_layer);
[n1,n2,n3] = size(future_grad);
grad{1} = future_grad .* mask;
grad{2} = real(future_grad .* input);
end
|
function [W]=clelz(D)
%these function clear low zero from a vector array
for p=length(D):-1:1
if D(p)~=0
break;
end
D(p)=[];
end
W=D; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.