text stringlengths 8 6.12M |
|---|
% Enum for the type of unit testing to be performed
%
% Author : Jonathan EDEN
% Created : 2017
% Description :
classdef TestModeType
enumeration
DEFAULT % Test model config, model and analysis
MODEL_CONFIG
MODEL_COMPONENTS
ANALYSIS
SCRIPTS
... |
function gui_init_cond(option)
% function gui_init_cond(option) ADVISOR 2.0
% This function lets the user select initial conditions for the simulation run
% <option> can be the string 'update' so that the edited variables will be updated
global vinf
drive=vinf.drivetrain.name;
if nargin==0
%set up colors
... |
function batch_backpropAnalysis()
cell_dirs = uipickfiles;
counter = 1;
data = {};
for i=1:length(cell_dirs)
ls_dir = dir([cell_dirs{i} '/*.mat']);
for j=1:length(ls_dir)
try
load([cell_dirs{i} '/' ls_dir(j).name]);
scans(counter) = obj.updateLineScanXML;
scans... |
function [u,r] = Gauss_Seidel_Poisson(u,b,tol,Nmax,dx,dy)
% Solves Poisson equation using Gauss Seidel iterations
% INPUTS:
% u : Initial guess
% b : RHS vector
% tol : Tolerance level
% Nmax : Max iterations
% dx : Grid spacing in x-direction
% dy : Grid spacing in y-direction
% OUTPUTS:
% u ... |
# -*- octave -*-
function [theta,f,e,in,s]=costas(in,fc,fs,alpha,beta, mode,n)
##Initialization
theta(1)= .0;
f(1) = fc/2;
e(1)=0;
x=abs(in(1));
y0=y1=0;
w0=w1=0;
phase_diff=0;
# [f,H,b]=raised_cosine(50,0.5,1/2400/2,fs);
[fb,fa]=cheby1(15,0.1,.4);
SF=zeros(15,1);
sig=0;
for I=2:length(in... |
function [targetFound, falseAlarms, targetFoundConf, alarmsToTarget] = ScoreAlarms(alarmLoc, alarmConf, targetList, confuserScore, halo)
s = size(alarmLoc);
targetFound = false(1, length(targetList(1).data));
targetFoundConf = -100000*ones(1, length(targetList(1).data));
falseAlarms = ones(1, s(1));
... |
function outIm = scaleBensImage(imdata, frameN)
quartiles = quantile(imdata,3);
im2 = imadjust(tempIm,[quartiles(1) quartiles(3)*1.5]);
im3 = imresize(im2,0.5);
%position = regexp(filename,'Seq\d+','match');
im4 = insertText(im3,[1 1],frameN,'FontSize',18);
outIm = im2uint8(rgb2gray(im4... |
function frames = extractFlyFrames(p)
% return frames cropped around the fly and rotated to align fly
p.framesToRead = unique(p.framesToRead);
frames = zeros(length(p.boxW), length(p.boxH), p.imageChannels, p.NumFramesToRead, 'uint8');
flyIdxIdx = p.framesToRead - p.fp.initFrame + 1;% convert frameidx to array indice... |
close all
clear
clc
cd('C:\Users\wdh130\Documents\NO-Modeling-Data\Vasomotion')
addpath('C:\Users\wdh130\Documents\NO-Modeling-Data\Vasomotion\WGN_NO_production')
addpath('C:\Users\wdh130\Documents\NO-Modeling-Data\Vasomotion')
tapers = [71 141];
[model] = TestVasomotion_v24(tapers);
figure(2),
subplot(2,... |
function [y1, y2]= crossover(x1,x2)
alpha=0.2;
y1=alpha.*x1+(1-alpha).*x2;
y2=alpha.*x2+(1-alpha).*x1;
end |
%
% Script for computation of average bulk density
%
% Directories to consider
dir_names = dir('seed_*');
dir_names = {dir_names.name};
ndirs = length(dir_names);
% All data
all_densities = zeros(ndirs, 1);
for i=1:ndirs
fname = dir_names(i);
path = sprintf('%s',fname{:});
% Move to path and execute the pyt... |
clear;
clc;
close all;
A = ones(7);
A(:,1) = 0;
A(:,7) = 0;
A(1,:) = 0;
A(7,:) = 0;
A(:,2) = 0;
A(:,6) = 0;
A(2,:) = 0;
A(6,:) = 0;
sq = ones(5);
%sq(:,1) = 0;
sq(:,4) = 0;
sq(4,:) = 0;
sq(:,5) = 0;
%sq(1,:) = 0;
sq(5,:) = 0;
sq2 = ones(10);
%se1 = strel('square',2);
A_d = imdilate(A,sq);
% B = imread('images/bina... |
%% Ej1: Obtencion de los angulos alfa y beta de las coordenadas esfericas.
% Sea el punto P(x,y,z) con {x, y, z} mis parametros.
% Introducimos los valores de nuestros parametros.
% prompt = 'Introduzca el valor de x ';
% x = input(prompt);
% prompt = 'Introduzca el valor de y ';
% y = input(prompt);
% promp... |
%--------------------------------------------------------------------------
% An example to show how ensemble ranking is working
%--------------------------------------------------------------------------
% Copyright @ Majid Mohammadi, 2020
% For more information, see the corresponding paper:
% Mohammadi and Rez... |
function plot_direction_select(PDS,sp,zchan)
debug = 0;
%********
gravedigger = 1;
Prelude = 0.3; % plot this many secs before onset
Postlude = 0.9; % plot this many secs after onset
Awin = 0.050;
Bwin = 0.550;
%*********************
Smoothing = 15; % in ms
PsthTime.Zero = floor(1000*Prelude);
PsthT... |
function rttargetcallback(hDlg, hSrc)
slConfigUISetEnabled(hDlg,hSrc,'RtTargetName', strcmp(get_param(hSrc.getModel,'ExtMode'),'off') );
if strcmp(get_param(hSrc.getModel,'ExtMode'),'off')
set_param(hSrc.getModel,'ExtModeMexArgs',slConfigUIGetVal(hDlg,hSrc,'RtTargetName'));
end
end
|
% exm2_ilaplace.m
% 例题2:拉普拉斯逆变换符号表示法
% 北京邮电大学,尹霄丽
% 2018年12月
syms s
F=exp(-2*s)/(s^2+3*s+2);
f=ilaplace(F);
|
function setMetadata(obj, metadata)
% SETMETADATA Sets metadata name-value pairs to be set with uploadMetadata
% This will overwrite any existing queue metadata. If this is set to an empty
% collection, the queue metadata will be cleared on an uploadMetadata call.
% Copyright 2019 The MathWorks, Inc.
if ~isa(metadata... |
f1 = h_newton.objval(h_newton.nu < 0);
f2 = h_fista.objval(h_fista.nu < 0);
%f3 = h_admm.objval(h_admm.nu < 0);
min_x = min([f1 f2]);
figure;
semilogy(f1 - min_x);
hold on;
semilogy(f2 - min_x, 'Color', [0 0.5 0]);
%semilogy(f3 - min_x, 'r');
% figure;
% semilogy(h_newton.time(h_newton.nu < 0), f1 - min_x);
% hold on... |
function batchSalcut(imfolder, exfolder)
% batch resize images to square pixel x pixel
% get image paths
imgs = imageDatastore(imfolder,'IncludeSubfolders',true,'FileExtensions',{'.jpg','.png'},'LabelSource','foldernames');
h = waitbar(0,'Segmenting images...');
for i = 1:length(imgs.Files)
image = imread... |
list = ['frame0000';
'frame0005';
'frame0010';
'frame0015';
'frame0020';
'frame0025';
'frame0030';
'frame0035';
'frame0040';
'frame0045';
'frame0050';
'frame0055';
'frame0060';
'frame0065';
'frame0070';
'frame0075';
'frame0080';
'frame0085';
'fram... |
function test_hyperbolic
% Test code for the quaternion sinh and cosh functions.
% Copyright © 2006 Stephen J. Sangwine and Nicolas Le Bihan.
% See the file : Copyright.m for further details.
disp('Testing hyperbolic functions ...');
T = 1e-11;
% Test 1. Real quaternion data.
q = quaternion(randn(100,100), randn(1... |
clear all
[daq,PathStress] = uigetfile('*.txt','Open data aquisition file');
cd(PathStress);
import=importdata(daq,'\t');
clear daq
if exist('import.data')==0
daq=import;
else
daq=import.data;
end
prompt = {'Which column is the experimental time?','Which column is the experimental stress?','Which column is the... |
function Handle = ArrowPlot2D(x,y,dx,dy,varargin)
% Pull 'Filled' option from parameter-value list
Mask = strcmpi(varargin,'filled');
Filled = any(Mask) ;
Options = varargin(not(Mask)) ;
% Columnify vectors
x = x(:)' ;
y = y(:)' ;
dx = dx(:)' ;
... |
% ======================================
% Cycle-slip detection
%
% zhen.dai@dlr.de
%
% last modified: 2011.Oct
% ======================================
% calculate high-order difference for a queue of data
function diffs=Method_Core_CalculateDifference(num_order, sequence)
numdata=length(sequence);
if length(seque... |
% This file implements Phase Coupling Optimization
% Written by Gunnar Waterstraat and Iara de Almeida Ivo
% Please obey the Licens file, supplied with this software.
% If you use this code in scientific work, please give proper reference
function [vlen, wy] = PCOa(a, y, nu, bestof)
% Phase Amplitude Couplin... |
% Bode diagram
num = [0 5 51 20 400];
denum = [1 12 60 300 250];
bode(num, denum);
title('Bode diagram of G(s)'); |
function WriteRtTgt(out_path, varargin)
% copy-paste test:
% WriteTrTgt('~/Documents/BLAM/finger-5/misc/tfiles/');
% More thorough example:
% WriteTrTgt('~/Documents/BLAM/finger-5/misc/tfiles/', ...
% 'day', 2, 'block', 4, 'swapped', [1 3],...
% 'image_type', 1, 'repeats', 5, ... |
function aitkenPicture(a,t,M)
% o history
% Daniel Klawitter
% created 05-11-2009 - 22:07
%
% o summary
% Generalization of the aitken algoritmus (see farin - CAGD)
% calls the aitken algorithmus for every subset of points and
% generates a plot, the user can improve it by setting colors etc
%
% ... |
% DisconnectBrick(brick);
clear();
global brick;
brick = ConnectBrick('NotGonnaWork');
beep(brick); |
function [ R_01 ] = r01_convert( data)
%This function converts hourly rainrate data to a finer scale. For now,
%only 60min-1min conversion is supported according to paper by Luini et. al.
% INPUT: 8760x11 data: hourly Rainrate values
%
%
% OUTPUT: 8760x11 R_01: Rainrate values on a 1-minute time sc... |
obj = load('Solver.mat');
obj = obj.Solver;
PostProcess = NdgPostProcess(obj.mesh2d(1),'StandingWaveInAClosedChannel/StandingWaveInAClosedChannel');
Ntime = PostProcess.Nt;
outputTime = ncread( PostProcess.outputFile{1}, 'time' );
Entropy = zeros( Ntime,1 ); ExactEntropy = zeros( Ntime,1 );
Energy = zeros( Ntime,1 ); E... |
% This code solves the model of Graham and Wright (2010, JME)
% Incomplete Information Version Using closed form solution
% Solve for PI equilibrium 2 where individual consumption is stationary, no
% random walk, idiosyncratic capital has explosive roots at z= beta
clear
close all
clc
% Parameters
beta = 0.99; ... |
%{
vis2p.StatsTracesParams (lookup) #
binsize : smallint unsigned # m) ms binsize for correlation computations
undersample : tinyint # m) undersample after bining
event_thr : tinyint # m) the multiplication factor of std for the threshold calculation
---
process="ye... |
function [fits, sems, p] = getML_LIPCTdependence(Monk, recompute)
savepath = ['/work/mirror_jeff/code/matlab/tmp-mat/getML_LIPCTdependence_' Monk '.mat'];
if recompute
a = getML_txt([Monk 'TRain_LIP.txt']);
fn = a.data{strcmp(a.name,'dat_fn')};
usable = a.data{strcmp(a.name,'usable')};
ses ... |
function h = get_average(g)
% This function gets the azimuthal average of a given field in polar grid
h = mean(g(:, 1:end-1, :), 2);
|
%% Recover ancient history - are the *input images* the same?
findVoxel = 31;
ancientResults = load(fullfile(rootpath, 'data', 'modelfits', '2014-06-24', 'results_V1_all_R=1_S=0pt5.mat'));
% findVoxel = 30;
% ancientResults = load(fullfile(rootpath, 'data', 'modelfits', '2014-06-24', 'results_V2_all_R=1_S=0pt5.mat'));
... |
%%% plot linear & log magnitue spectrum of signal
% generate signal
Fs=10000; % in Hz
F1=1000; % in Hz
F2=2000; % in Hz
duration=2; % in seconds
nSamples=100;% number of signal samples for plotting
t=0:1/Fs:duration;
y=2*sin(2*pi*F1*t)+1*sin(2*pi*F2*t); % signal of 2 frequencies
sound(y,Fs);
figure(1)
% norma... |
function varargout = wmspcatool(varargin)
%WMSPCATOOL Multisignal Principal Component Analysis GUI.
% VARARGOUT = WMSPCATOOL(VARARGIN)
% Last Modified by GUIDE v2.5 04-Sep-2006 13:21:28
%
% M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 29-Mar-2005.
% Last Revision 29-Apr-2012.
% Copyright 1995-2012 The MathWo... |
function [featvals names]= Lharalick_img_nuclei_wise(img,mask,Num_level)
%
% img: org tissue image.
% mask: nuclei mask
% Num_level:8
%
% feats = haralick_img_nuclei_wise(img,mask,Num_level)
% cheng adapted haojia's function here
%function feats = haralick(img,fg_bg_mask,graylevels,hws,dist,fg_bg)
%fg_bg_... |
function E = getErrorClass(theta, D)
X_C = D(1,:);
Y = D(2,:);
X_E = D(3,:);
n = size(D,2);
mu_Y = theta(1);
mu_0 = theta(2);
mu_1 = theta(3);
sigma_Y = 1;
sigma_0 = 1;
sigma_1 = 1;
prob = 1 ./ ( 1 + (sigma_1 / sigma_0) * exp( - 0.5 * ( ...
((X_E - mu_0)/sigma_0).^2 - ((X_E - mu_1)/sigma_1).^2 ) - ..... |
%% Stelling 12
%
% Met behulp van de functie addall() kunnen de waardes
% van een vector bij elkaar worden opgeteld.
%
Antwoord = NaN; % vul hier het juiste antwoord in 1 (WAAR) of 0 (ONWAAR)
|
function r = moving_stddev(x,w)
% Moving variance
%
% v=movingvar(x,m)
%
% x is the timeseries.
% m is the window length.
% v is the variance.
%
% Aslak Grinsted 2005
% n=size(x,1);
% f=zeros(m,1)+1/m;
%
%
% v=filter2(f,x.^2)-filter2(f,x).^2;
% m2=floor(m/2);
% n2=ceil(m/2)-1;
% v=v([zeros(1,m2)... |
function beamGeometry(SAD, ADD, spacingDet, noViews, fillingPositions, fillingDiameters, marginPixelsOnDetector)
% beamGeometry(SAD, ADD, spacingDet, noViews, fillingPositions, fillingDiameters, marginPixelsOnDetector)
%
% computes the geometric parameters of a set of beams that are collimated
% onto the given position... |
function [ fext ] = getInitialFunction( obj )
fext = cell( obj.Nmesh, 1 );
for m = 1:obj.Nmesh%Íø¸ñÑ»·
fext{m} = zeros(obj.meshUnion(m).cell.Np, obj.meshUnion(m).K, obj.Nfield);%´óСNp*K*Nfield
a = obj.meshUnion(m).y;
tx = -0.2*cos(3.1415927*a/1000000);
fext{m}(:,:,1) = 1000;
fext{m}(:,:,7) =... |
function Q = Adj2Q(A)
%Adj2Q compute the transition matrix for an adjacency matrix
% [Q] = Adj2Q(A) : if A is an adjacency matrix, Q is the corresponding
% transition matrix
sumRows = arrayfun(@replaceZero,sum(A, 2));
sumMat = repmat(sumRows, 1, size(A, 2));
Q = A ./ sumMat;
end
function y = replaceZe... |
% I = PATCH_INPAINT(Iorg, Mask, verbose) inpaints an image
%
% Iorg - original image
% Mask - replacement mask; pixels where mask==1 will be inpainted
%
% I - inpainted image
function A = patch_inpaint(Aorg,Morg, verbose, sigma)
if nargin < 3
verbose = true;
end
if nargin < 4
sigma = 0.1;
end
... |
function [QR,d]=qrzerlegung(A)
[n,m] = size(A);
d = zeros(m,1);
for i=1:m
v = zeros(n-i+1,1);
w = zeros(n-i+1,1);
wnorm = 0;
for j=i:n
w(j-i+1) = A(j,i);
wnorm = wnorm+(w(j-i+1)**2);
endfor;
if w(1)==0
w(1) = w(1)+sqrt(wnorm);
else
w(1) = w(1... |
classdef Graph < handle
properties(Access=public)
rootNode
nodes
adjMatrix
end
methods
function this = setRootNode(this,n)
this.rootNode = n;
end
function this = addNode(this,n,h)
this.nodes=[this.nodes n];
n.hN=... |
function [forman, kiebel, conv] = stat_smoothness_sims( mask, nsubj_vec, FWHM_vec, niters, savefilename )
% STAT_SMOOTHNESS_SIMS runs stationary smoothness estimation simulations
%--------------------------------------------------------------------------
% ARGUMENTS
% Mandatory
% mask the mask on which to genera... |
function out=flyVacMLBS(data)
MLs=zeros(1,1000);
numFlies=size(data,1);
for i=1:3000
which=ceil(rand(numFlies,1)*numFlies);
resample=data(which);
temp=flyVacML(resample);
MLs(i)=temp.ML;
end
temp=flyVacML(data);
out.ML=temp.ML;
out.MLstd=std(MLs);
|
clear all
dd = '';
fd = '';
fs = 25; fs2 = 15; lw = 4; lw2 = 2; ms = 20; ms2 = 9;
load([dd 'native_scan.mat']);
aks_native = aks;
load([dd 'synex_scan.mat']);
aks_synex = aks;
load([dd 'pi2_inflection.mat']);
load([dd 'pi2_dkl.mat']);
load([dd 'native_fit_cdf.mat']);
kstar_native1 = kstar;
load([dd 'native_fit_cdf2.ma... |
function [chains, chainInfo] = createChains(grouping, angles, compInfo)
% Create chain of components based on a certain set of rules.
% Input:
% groups: an NXN binary matrix. where groups(i,j) = 1 if the
% components i and j are compatible.
% angles: an NXN matrix, where a... |
directory = 'testsets\centerfaces';
allnames=struct2cell(dir(strcat(pwd,'\',directory,'\*.pgm')));
namelist = ones(size(allnames,2),1);
[k,len]=size(allnames);
%resultsRecords = [];
for index=1:size(namelist,1)
if(namelist(index)==1)
%realDir = strcat(directory,'\*.jpg');
fileName1=a... |
function shocks = DetectShocks(FileBase, Channel)
% Detects delivered shocks (ie from Coulbourn conditioning cage) based on
% simple criteria looking for a flat square wave of a certain duration and time
% Input FileName is a filename
% Output shocks is a 2 column array, first column is start time of each event, 2nd ... |
function [newrows]=selectrows(rownums,matrix)
% selects rows from a matrix
% useage selectrows(rownums,matrix)
newrows=matrix;
for trial=1:size(matrix,1)
if (~ismember(trial,rownums))
newrows(trial,:)=zeros(1,size(matrix,2))-Inf;
end
end
[newrows,indices,reconstruct]=unique(newrows,'rows');
newrows=... |
function out1 = hess_grf_ceq_heel513(in1,toe_th,dmax,cmax,k,us,ud)
%HESS_GRF_CEQ_HEEL513
% OUT1 = HESS_GRF_CEQ_HEEL513(IN1,TOE_TH,DMAX,CMAX,K,US,UD)
% This function was generated by the Symbolic Math Toolbox version 8.4.
% 23-Jun-2020 09:44:24
out1 = 0.0;
|
function options = checksoptions (options,T)
% Right now the option S is not implemented for stochastic learning
N = length(T);
% data options
if ~isfield(options,'Fs'), options.Fs = 1; end
if ~isfield(options,'embeddedlags'), options.embeddedlags = 0; end
if ~isfield(options,'pca'), options.pca = 0; end
if ~isfield... |
function [RSU_FM,RSU_M]=RSAnalysis(img,G_x_length,G_y_length)
[r,c]=size(img);
digit_img=double( img(:,:,1) );
img_M=digit_img;
img_FM=digit_img;
for x= 1 : r
for y= 1 :c
if rem(digit_img(x,y), 2 )==0
img_M(x,y)=img_M(x,y) + 1;
img_FM(x,y)=img_FM(x,y)-1;
... |
%% Read actual masks from server
% This script requires LabelMeToolBox
% Define the root folder for the images
HOMEIMAGES = '.\Images'; % you can set here your default folder
HOMEANNOTATIONS = '.\Annotations'; % you can set here your default folder
HOMEMASKS = '.\Masks\'; % you can set here your default folder
% usc_... |
function [FFBC,SOL,sysDex] = GetAdjust4CBC_SSPRK53(BC,NX,NZ,OPS,FF)
numVar = 4;
SOL = 0.0 * FF;
% Adjust for the boundary forcing
FFBC = FF;
%% Create boundary condition indices
%
ubdex = 1:NZ:OPS;
wbdex = ubdex + OPS;
rbdex = ubdex + 2*OPS;
pbdex = ubdex + 3*OPS;
BotOut = [... |
function [ ] = driver_obs( );
% driver for obs.m
%
% "OBS: MATLAB Solver for L-SR1 Trust-Region Subproblems"
% by Johannes Burst, Jennifer Erway, and Roummel Marcia
%
% Copyright (2015): Johannes Brust, Jennifer Erway, and Roummel Marcia
%
% The technical report and software are available at
% www.wfu.edu/~erwayjb/pub... |
% 对椭圆进行拟合
% x,y代表对应的坐标向量,varargout为结构体
% 有5个数值 Xc Yc A B Phi 和一个向量 P
% 椭圆一般方程
% P(1)x^2+P(2)xy+P(3)y^2+P(4)x+P(5)y+P(6)=0
% 椭圆参数方程
% X(t)=Xc+Acos(t)cos(Phi)-Bsin(t)sin(Phi)
% Y(t)=Yc+Acos(t)sin(Phi)-Bsin(t)cos(Phi)
function [varargout]=ellipsefit(x,y)
%------------------------------------------------... |
function [img] = Run(obj,img)
%Run Summary of this function goes here
% Detailed explanation goes here
img = imfilter(img,obj.H,'replicate');
end
|
function [ RRMSE_Original, RRMSE_Achieved,Current_Iterative_Image,objective_array ] =myMainScript(alpha,gamma,prior_type)
load('../data/assignmentImageDenoisingPhantom.mat');
%initialization
InputImage = imageNoisy;
Current_Iterative_Image = InputImage; % Guess of input image
Prev_Iteration_Image = ones(size(i... |
tol = 1e-10;
%% Tri: N = 3
N = 3;
tri = StdRegions.Triangle(N);
Dr_ext = load('DrDs_Test/Dr_3.cc');
Ds_ext = load('DrDs_Test/Ds_3.cc');
for i = 1:tri.nNode^2
assert( abs(tri.Dr(i) - Dr_ext(i)) <= tol);
assert( abs(tri.Ds(i) - Ds_ext(i)) <= tol);
end
%% Tri: N = 4
N = 4;
tri = StdRegions.Triangle(N);
Dr_ext ... |
%% MRDataEllipse.m
%
% Returns the MR data corresponding to the indicator function of an ellipse
% that is modulated by a polynomial or sinusoidal profile, for the given
% kspace samples.
%
% Matthieu Guerquin-Kern, Biomedical Imaging Group / EPF Lausanne,
% 31-10-2009 (dd-mm-yyyy)
function m = MRDataEllipse(ellipse,s... |
function normcorremotioncorrection(name,tempname)
addpath('/home/jvg219/NoRMCorre-master/')
% name = ['/experiment/TwoPhoton/2P_Detection/JG8432/170120/Template/' name];
% tempname = '/experiment/TwoPhoton/2P_Detection/JG8432/170120/Template/green/Template_green.tif';
tic; Y = read_file(name); toc; % read the file (o... |
function [FBdown,x,y,z] = render_vol(I, factorDown, noiseThreshold)
arguments
I
factorDown = 2
noiseThreshold = 1.8
end
FB = double(I*255.0);
[nFy,~,nFz]=size(FB);
FBt =FB(:,:,:);
ny=round(nFy/factorDown); nx=round(nFy/factorDown); nz=round(nFz/factorDown); %% desired output dimensions
[y, x, z]=ndgrid(lin... |
% xAverageDistances.m
%
% use the function xVesselDistances to figure out a relationship between
% vessel radius and average distance to closest vessel
clear; clf;
p = gentemplate;
p.vesselFraction = 0.02;
nReps = 100; % number of repeats to do at each radius
R = (10:5:200)*1e-6; % range from 10 to 200 um
Dists = ... |
function [gammatone] = MakeGammaTone(Fs,freq,dur)
%[gammatone] = MakeGammaTone(Fs,freq,dur)
%MakeGammaTone: Create a gammatonal stimulus
%Fs: sampling rate in Hz
%freq: frequency in Hz
%dur: duration in ms
if(nargin < 3)
error('Not enough input arguments');
end
dur = dur/1000;
numpts = Fs * dur;
... |
function obj = rmfieldsFcnHandles(obj)
fs = fieldnames(obj);
for ii = 1:numel(fs)
if isa(obj.(fs{ii}), 'function_handle')
obj = rmfield(obj, fs{ii});
elseif isa(obj.(fs{ii}), 'struct')
obj.(fs{ii}) = tools.rmFcnHandles(obj.(fs{ii}));
end
end
end
|
function qqRamsey(varargin)
% qqRamsey: two qubits ramsey for the calibration of the phase offset between
% two qubits by simultaneously applying a 90 deg. X pulse on qubit1 and and a 90 theta
% pulse on qubit2, where theta is an adjustable microwave phase angle. A plot of the
% occupation probabilities versus free evo... |
clear;
clc;
A=imread('fitnut.jpg')
[m,n,k]= size(A);
esikdeger =90 ;
B=A;
for c = 1:m
for r = 1:n
for p = 1:k
if(B(c,r,p)<esikdeger)
B(c,r,p)=0;
else
B(c,r,p)=255;
end
end
end
end
imshow(B); |
function accuracy = K_NN(Train_D_P,Test_D_P,L_Test,K)
%
% This function implement the k-NN rule.
%
% accuracy = K_NN(Train_D_P,Test_D_P,L_Test,K)
%
% Train_D_P - training data (each column is an observation)
% Test_D_P - testing data (each column is an observation)
% L_Test - true label of testing data
% K - a designed... |
clc
clear
close all
NO = 80;
NX = 200;
L = 2 * pi;
[xh,~] = herdif(NX, 2, L, false);
[xphys,ddx_phys] = herdif(NX, 2, L, true);
xfft = linspace(-L,L,NX);
[~,~,w]=hegs(NX);
W = spdiags(w, 0, NX, NX);
[~, HT] = hefunm(NO-1, xh);
[~, HTD] = hefunm(NO, xh);
%% SIMPLE FUNCTION TO DIFFERENTIATE EXACTLY WITH HERMITE FUN... |
function f = factorizedLU(A)
% f = factorizedLU(A)
% can I produce a factorized function just like I had in python?
% YES! wow.
% returns a function that solves the system Ax = b. that is f(b) =
% x;
[L U P Q R] = lu(A);
f = @(x) Q*(U\(L\(P*(R\x))));
|
function this = parseFunctions(this)
dataStruct = this.data.(this.activeGroup);
for field = this.functions
if ~isempty(field.timeField)
field.src.time = dataStruct.(field.timeField);
end
end |
function [ mq, Sigmaq Lambdaq] = opperGetMeanParam( omegaq, eta, Sigmap, invSigmap )
%OPPERGETMEANPARAM Get mean parameters from Opper parameterization
% Detailed explanation goes here
% mq = (Sigmap)(omegaq) --> omegaq = (Sigmap{^-1})(mq)
% Sigmaq = (diag(eta) + So^{-1})^{-1}
mq = Sigmap*omegaq;
Lam... |
%Script to test various ways of producing an "optimal" ILD/Freq response surface from
%a measured ILDAlone spatial response surface
clear;close all
nntwarn off %needed to suppress warning messages regarding obsolete neural network functions
%Input needed for functions below
bird_number = 899;
side_of_brain = ... |
function [ result, message ] = op_FRAP_Analysis( data_handle, option, varargin )
%OP_FRAP_ANALYSIS does fitting of XT FRAP trace or traces
% Using double exponential model here
result=[];message='';
parameters=struct('note','',...
'operator','op_FRAP_Analysis',...
'parameter_space',{'frac_bleached','frac_rec... |
z1 = complex(1,2)
class(z1) |
function z = zcr(x)
z = sign(abs(diff(sign(x))));
return
end |
function normalize(obj)
mag = sqrt(obj.x^2 + obj.y^2);
obj.x = obj.x / mag;
obj.y = obj.y / mag;
end
|
function plotlysetup(un, api_key, varargin)
% [1] adds plotly api to matlabroot/toolboxes. If successful do [2]
% [2] adds plotly api to searchpath via startup.m of matlabroot and/or userpath
% [3] calls saveplotlycredentials
% [4] calls saveplotlyconfig
% [TODO]: Account for octave users
% [TODO]: Test on windows mach... |
%stub for implementing Zalesky 2014, PNAS model
% Stolen code to make good matrices
% load('subject4session1_PowerPetersen_allSpheres_wraf_sig.mat')
% names=fieldnames(sys);
%
% %convert to matrix
% regions = length(names);
% timepoints = length(sys.(names{1}));
%
% ts_conn = zeros(regions, timepoints);
% for i = 1:... |
function rgb=color2YUVinv(Y,U,V)
d1=size(Y,1); d2=size(Y,2); d3=size(Y,3);
rgb=zeros([d1 d2 3 d3]);
rgb(:,:,1,:) = Y +1.13983*V;
rgb(:,:,2,:) = Y -0.39465*U -0.58060*V;
rgb(:,:,3,:) = Y +2.03211*U ;
|
function [r1,c1,finish,Hn_next,Wn_next,iw,ih]=modifiy_Hilbert2D_ScanByBlock(r,c,Hn,Wn,Hn0,idxW,w,iw,h,ih,p2s)
%For the current block: 'Hn' fixed, 'Wn' decreasing, i.e. 'iw' increases, but 'ih' is fixed.
Hn_next=Hn0; Wn_next=h(ih); %For the next block: 'Wn_next' fixed, 'Hn_next' decreasing, Note, Hn0
... |
function result = testtypes()
v.a = 'foo'
v.b = 3.1415
v.c = [ 0 1 2; 3 4 5 ]
v.d = { 'bar', 'baz', 'bazz' }
v.e = ( 0 == 1 )
v.g(1).a(1) = { 'g1a1' }
v.h = 4 + 3*i
result = v;
endfunction
|
function [ fig ] = visualize_surf_single( f,N,lb,ub )
fig = figure;
x = linspace(lb,ub,N);
y = x;
[X,Y] = meshgrid(x,y);
Z = get_Z_from_meshgrid_f(X,Y,f);
surf(X,Y,Z);
ylabel('weight W_2')
xlabel('weight W_1')
zlabel('Loss')
end
|
%Uncentred
error1 = [1,0];
error2 = [1,0];
error3 = [1,0];
error4 = [1,0];
error5 = [1,0];
error6 = [1,0];
error7 = [1,0];
error8 = [1,0];
error9 = [1,0];
error10 = [1,0];
error11 = [1,0];
error12 = [1,0];
error13 = [1,0];
error14 = [1,0];
error15 = [1,0];
error16 = [1,0];
error17 = [1,0];
error18 = [... |
function [ Ncell, EToV ] = InitTriConnect2d(N)
%InitTriConnect2d - Description
%
% Syntax: [ Ncell, EToV ] = InitTriConnect2d(mesh)
%
% Long description
Np = ( N + 1 ) * ( N + 2 ) / 2;
Ncell = N ^ 2;
EToV = zeros(3, Ncell);
sk = 1;
s2 = Np;
s1 = Np - 2;
for row = 1 : N
v1 = s... |
function num = compute_fcollect_feature_size(feature_list)
num = 0;
for i = 1:length(feature_list)
num = num + size(feature_list{i}, 1);
end
end
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
% Handwritten digits classification using Baysian classifier
% Principal Component Analysis & Maximum Likelihood Classifier
%
% Input: dmax (which is 60 in this exercise)
% Output: a plot of classification errors (from d = 1 to dmax),... |
%visulatization of 3D printing thermal histories
%Author: Jordan Kruse
%visulatization of 3D printing thermal histories
%Author: Jordan Kruse
%clear MATLAB
clc,clear
%begin timing gcode processing
tic
a = 275; %accel in mm/s^2
max_jerk = 5;
%convert GCODE file to matrix and seperate variables
%NOTE: gcode must not... |
clear all
clear
clc
t1 = -10:0.1:-2;
t2 = -2:0.1:0;
t3 = 0:0.1:2;
t4 = -10:0.1:10;
y = sign(t1, t2, t3, t4);
figure
stem(t,y,'r*')
axis([-2 2 -1.5 1.5])
grid on |
function d=pdist_tmh(X);
[n,ndim]=size(X);
d=zeros(n,n);
for i=1:n;
for j=i:n
dd=sqrt(sum((X(i,:)-X(j,:)).^2));
%
%dd=edist(X(i,:),X(j,:));
d(i,j)=dd;
d(j,i)=dd;
end
end
|
function [wPtr] = loadRGBLinCalib(wPtr)
% ----------------------------------------------------------------------
% [wPtr] = loadGRAYLinCalib[wPtr]
% ----------------------------------------------------------------------
% Goal of the function :
% Load necessary values to specified RGB and Gray Values in candela/m2
% a... |
% SetInfo_AM
% combines all the other 'set...' scripts into one
if get(H.spaceflag,'Value') & (XStimParams.space_flag == 0)
XStimParams.space_flag = 1;
XStimParams.ildalone_flag = 0;
XStimParams.itdalone_flag = 0;
elseif get(H.ildaloneflag,'Value') & (XStimParams.ildalone_flag == 0)
XStimPara... |
% Loss_euclidean Compute Euclidean distance from the prediction and the
% ground truth
%
% [L, dLdy] = Loss_euclidean(y_tilde, y) computes the euclidean distance
% given prediction y_tilde and ground truth y.
%
% Input:
% y_tilde = mx1 prediction vector
% y = mx1 ground trut... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.