text stringlengths 8 6.12M |
|---|
function [P]=InterpolationPolynomial(x,y)
sample_size = length(x);
lagrange_basis_polynomials = zeros(sample_size);
for i = 1:sample_size
lagrange_basis_polynomials(i) = LagrangeBasisPolynomial(x, y, i);
end
P = @(x) y*
end |
% This program solves a convection-diffusion problem in the domain proposed in HM1
%
clear, close all, home
global diffusion
disp(' ')
disp('This program solves a diffusion equation on the HM-1s geometry')
disp(' ')
disp('No source term is considered')
disp(' ')
disp('Diffusion coefficient = 1');
diffusion = 1... |
% vector: type of native Matlab vector
function result = bootstrap(vector)
base_interval = 1;
interval = base_interval;
result = do_bootstrap(vector, interval);
while (isempty(result))
interval = interval + base_interval;
result = do_bootstrap(vector, interval);
end
end
% vector: ty... |
purge
%%%Ok so here we are going to test all of the magnetorquer controllers
%%%Initial State of the satellite
phi = 0;
theta = 45*pi/180;
psi = 0;
p = 0.1;
q = 0;
r = 0;
q0123 = euler2quat([phi,theta,psi])';
state = [q0123;p;q;r];
timestep = 0.1;
tout = 1:timestep:3000;
stateout = zeros(length(tout),length(state))... |
function exit_fig
set(0,'ShowHiddenHandles','on');
delete(get(0,'Children')); |
function jfnk = JFNK(config)
% Default parameters
jfnk = IntrepidTwilight.TenaciousReduction.Solver();
jfnk = jfnk.changeID(jfnk,'JFNK');
% Parameters
jfnk.set('tolerance.residual' , 1.0E-7 ) ;
jfnk.set('tolerance.stepSize' , 1.0E-7 ) ;
jfnk.set('maximumIterat... |
function sigout=tpss(sigin,fs,ts,ps)
% function to perform Time Scaling and Pitch Shifting (TPSS)
% sigin: input signal
% fs: sample rate
% ts: scalar time scaling factor
% ps: 2 element vector of pitch shifting curve
% [initial_pitch_shift, end_pitch_shift]
%
% returns sigout: the shifted and/or scaled audio
%
... |
function inputs = getBatch_MSLapSRN(opts, imdb, batch, mode)
% -------------------------------------------------------------------------
% Description:
% get one batch for training MS-LapSRN
% We equally split a batch for multiple scales (opts.scales)
%
% Input:
% - opts : options generated from ... |
thres=1;
c=8;%确定C的数目
timethres=5;
load('TrainingSamplesDCT_8_new.mat');
%导入预先数据
%算出255x270的图像每个pixel的1-64的dct值
pict=imread('cheetah.bmp');
pict=im2double(pict);
pictpad=zeros(300,300);
pictpad(1:255,1:270)=pict;
pict2vec=zeros(255,270);
zigzag=textread('Zig-Zag Pattern.txt','%u',-1)+1 ;
%导入mask
picttest=imread('chee... |
clear
num=40;
a=5;
theta=linspace(0,2*pi,num);
r=a*(1-cos(theta));
x=r.*cos(theta);
y=r.*sin(theta);
plot(x,y,'.--','markersize',10,'linewidth',1.1)
P=[x;y]';
Pname=['fig5_1-',num2str(num),'.mat'];
pathname='C:\CodeStore\matlab\几何迭代法\data\';
save([pathname,Pname],'P')
axis equal |
function outputResult( obj, time, field )
% output time
startInd = obj.outputStep;
countInd = 1;
netcdf.putVar(obj.ncid(obj.fileOrder), obj.timeVarableId, startInd, countInd, time);
% output physical field
startInd = [ 0, 0, 0, obj.outputStep ];
countInd = [ obj.mesh.cell.Np, obj.mesh.K... |
% function [BlueMMs, Count] = MATLABTask2(img)
% cform = makecform('srgb2lab');
% lab_img = applycform(img,cform);
% ab = double(lab_img(:,:,2:3));
% nrows = size(ab,1);
% ncols = size(ab,2);
% ab = reshape(ab,nrows*ncols,2);
%
% nColors = 7;
% [idx, c] = kmeans(ab,nColors,'distance','sqEuclidean','Replicates',1);
% s... |
function yint = Interpolacion_Newton(xi, x, y)
N = length(x);
f = zeros(N, N);
for n=1:N
f(n, 1) = y(n);
end;
for m = 2:N
for n = 1:N+1-m
f(n,m)=(f(n+1,m-1)-f(n, m-1))/(x(n+m-1) - x(n));
end;
end;
yint = f(1,1);
dx = 1;
for n=2:... |
image_dir = 'E:\lane\GM_deeplane\data\data_l\real data\night_l\';
fid_txt ='train.txt';
files = dir(strcat(image_dir,'*.jpg'));
for k = 1:length(files)
%k=1;
final_y = 360;
%Load picture
image_name = files(k).name;
RGB1 = imread(strcat(image_dir,image_name));
image = imrotate(RGB1,180);
%Set the abrupt value of R... |
function [output] = mySpatiallyVaryingKernel(input,mask,threshold,dist_mat)
%MY Summary of this function goes here
% Detailed explanation goes here
input = im2double(input);
[row,col,nChannels] = size(input);
% dist_mat = bwdist(mask);
% dist_mat(mask~=0) = 0;
% dist_mat(dist_mat>threshold)=threshold;
% figure,images... |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Subject: Engineer Tools
% File: Attestation 3 - SW09 ("sw09.m")
% Author: Ervin Mazlagic
% Date: April 14, 2013
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Preparations
clear; clc;
pkg load ode... |
% How to creat folders
clc ;
clear ;
for k=1:2
failname = dir('C:\Users\uos\Documents\Gaussian_Process\DataFromMatlab\ssdf_data\train_data\*.*') ;
[row col ] = size(failname);
for i =3:row
path = ['C:\Users\uos\Documents\Gaussian_Process\DataFromMatlab\ssdf_data\train_data\' failname(i).name] ;
str = ['ui... |
addpath /Users/fschneider/ownCloud/Shared/MWorks_MatLab
addpath /Users/fschneider/Documents/GitHub/CPR/Matlab
%% Import files
fname_cpr = {
'20210204_bew_CPR_fxs.mwk2';
'20210204_fxs_CPR_fxs.mwk2';
'20210204_kan_CPR_fxs.mwk2';
'20210204_mac_CPR_fxs.mwk2';
'20210205_lac_CPR_fxs.mwk2';
'20210... |
function vp = kfinddip(topo, level, border, minarea)
% vp = ltfinddip(record, level, border, minarea)
if nargin < 3, border = 0; end
if nargin < 4, minarea = 4; end
atomdata = regionprops(topo < level);
vp = reshape([atomdata.Centroid],2,length(atomdata))';
% remove one pixel
vp([atomdata.Area] < minarea,:) = [];
%... |
n = 32; % signal is n x n (possibly complex valued)
n_illumin = 8; % number of structured illumination patterns
% Set signal and illumination patterns
x0 = randn(n,n) + 1i*randn(n,n);
Pattern = randn(n,n,n_illumin) + 1i*randn(n,n,n_illumin);
%Pattern = round(rand(n,n,n_illumin));
% Generate ... |
%% "Project: Large scale interactions in the cortico-hippocampal network"
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%STUDENT: Ramiro Adri??n Alem??n Zapata. Master Student @ TU Eindhoven.
%ADVISORS: Francesco Battaglia and Lisa Genzel
%Donders Institute of ... |
%% This script does all the preprocessing steps from the 4D light reconstructed data set, to a dataset ready to be analysed using PCA and ICA
% The steps are:
% * Detrending the data with the signal boxed averaged over 10 s. This allows to center the data and to remove decrease in fluorescence from fluorophore bleachi... |
function c = split_string(str)
% c = split string
n = 1;
not_done = true;
while not_done
[a b] = strtok(str);
if (isempty(a)==1)
not_done = false;
else
c(n) = cellstr(a);
str = b;
n = n+1;
end
end
|
function [cluster,clf_names,clf_time] = MyClustering ...
(X,param,clf_select)
allnames = {'Hierachical cutoff<2','Hierachical cutoff>=2','k-Means',...
'k-Medoids','DBSCAN','Mean shift','Best k-Means','Spectral Clustering'...
'Gaussian Mixture Models','test'};
clf_names = allnames(clf_... |
function demo_vis_script
global VIS;
% start w/ clean slate
initVis;
for n = 1:VIS.num_nodes
for i = 1:3
m = ceil( rand(1) * VIS.num_nodes );
VIS.node(n).anchor(i).nodeIdx = m;
VIS.node(n).anchor(i).dist = 10*rand(1);
m = ceil( rand(1) * VIS.num_nodes );
... |
clc;close all; clearvars;
im = iread('im13.jpg');
gamma=0.8;
% im = iread('3_shapes.png');
im = imresize(im, [300 NaN]);
imr = double(im(:,:,1))./255.0;
img = double(im(:,:,2))./255.0;
imb = double(im(:,:,3))./255.0;
imr=imr.^gamma;
img=img.^gamma;
imb=imb.^gamma;
imR = (imr./(img+imb+imr));
imG = (img./(img+imb+imr));... |
function plotHabituationCurve(comb)
% input comb is matrix (fly x choice #) with all odor choices made by each
% fly during the experiment. Entries are logicals (1 = Air choice) and
% empty cells are filled with NaN.
[phat, pci] = binofit(sum(comb == 1), sum(comb == 1) + sum(comb == 0));
maxCount = 35;
figure
hold ... |
function varargout = start_gui(varargin)
%UNTITLED1 MATLAB code file for untitled1.fig
% UNTITLED1, by itself, creates a new UNTITLED1 or raises the existing
% singleton*.
%
% H = UNTITLED1 returns the handle to a new UNTITLED1 or the handle to
% the existing singleton*.
%
% UNTITLED1('Property... |
function A = stellar_proc_post_rotation(A,m)
if length(A.mtime)==0
return
end
if ~isfield(A,'info')
A.info = {};
end
%% Error velocity threshold
evel_max = 0.1;
rm = abs(A.error_vel) > evel_max;
A.east_vel(rm) = NaN;
A.north_vel(rm) = NaN;
A.vert_vel(rm) = NaN;
A.error_vel(rm) = NaN;
A.info{length(A.info)+1}... |
%% test mex for dcimg
%% clear all
clc;
clear all; %#ok<CLSCR>
%% open dcimg
% hdcimg : dcimg handle
% 'FILENAME' : dcimg file name
cd('C:\Users\sCMOS-1\Desktop\Experiment_test')
[FILENAME, PATH, ~] = uigetfile('*.dcimg');
cd(PATH)
FILENAME = cat(2, PATH, FILENAME);
hdcimg = dcimgmex( 'open',... |
% A parameterised representation of cable attachment locations
% where cables are attachable on a cylindrical frame (with fixed radius)
% used for cable attachment optimisation
%
% Author : Darwin LAU
% Created : 2016
% Description :
% It is currently assumed that cylinder is centred at (0, 0, 0) and ... |
function output = latConverter(input)
% USPEX Version 4.2.1
% Change: interfaced with SIESTA
% transformation between matrix and parameter representation of the
% lattice.
if size(input,1) ==3
% since this if-clause is fulfilled the input is a matrix, so we
% calculate the parameters
output = zeros(6,1)... |
function load_standard_bus_selection_rules
%% load_standard_bus_selection_rules.m
global params
r = global_jess_engine();
r.eval(['(bind ?standard_bus_selection_rules_clp "' params.standard_bus_selection_rules_clp '")']);
r.eval('(batch ?standard_bus_selection_rules_clp)');
if strcmp(params.CASE_STUDY,'EOS')
jess ... |
x = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0];
N = 10;
n = 0:1:N-1;
j = sqrt(-1);
subplot(4,1,1)
X = DFTsum(x);
stem(n, abs(X))
title('mag(DFTsum(δ(n)))')
xlabel('n')
ylabel('mag(DFT(δ(n)))')
subplot(4,1,2)
x = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
X = DFTsum(x);
stem(n, abs(X))
title('mag(DFTsum(1))')
xlabel('n')
ylabel('mag(DFT(1)... |
% connect to kx
h = kx('localhost',5001)
|
function err=getL2Error_local_p_dg(pp,p,h)
GaussP=[-0.7745967 0 0.7745967]; %高斯点
GaussA=[0.5555556 0.8888889 0.5555556]; %高斯系数
x= 0:h:1; %区间[0,1]
err=0;
F=zeros(length(x)-1,1);% n
for i=1:length(x)-1
points = h/2*Gaus... |
function s = proposition_good3(grid, row_not_def, col_not_def, mask_row, mask_col, mask_square, grid_init)
% grid: 9x9 matrix representing a full grid
% row_not_def: the row indices of the non-defined values
% col_not_def: the col indices of the non-defined values
% Swap two element that are not defined.
% The element... |
function [constit, desc] = importIndexConstituents(path2zip)
% IMPORTINDEXCONSTITUENTS Imports the zipped COMPUSTAT index constituents web-query into a table
%
% IMPORTINDEXCONSTITUENTS(PATH2ZIP)
zipfile = 'COMPUSTATindexConstQuery.csv.zip';
writeto = '.\results';
% Unzip and loadf as row strings
csvfile = unzip(fu... |
function [ compacted ] = util_compact_spif_spikevalues( spv )
%UTIL_COMPACT_SPIF_SPIKEVALUES 工具函数:将SPIF中SPIKEVALUE信息压缩
% 将SPIF中SPIKEVALUE表中,每一个SPIKE的信息缩减为只包含最大值和最小值。
% 这样在处理较大SPIKE文件(尤其是长时间记录文件)时,可以不至于内存报错。
%
% 蒲江波 2009年6月17日
compacted = cell(64,1);
for i = 1:64
compacted{i} = [max( spv{i} ); min( s... |
% average some branches
function average_branches
% define base path
BasePath = uigetdir('Open base directory:','C:\');
% default
confirmselection = 1;
filecounter = 1;
% use UI to get files
while confirmselection==1
[filename,path] = uigetfile('*.dat','Open branch file:',BasePath);
filepath =... |
classdef ImageStackApp < handle
% IMAGESTACKAPP View a stack of EM screenshots
% Inputs:
% images ImageStack or filepath to images
% Provide a 2nd input to reverse the stack
properties (Transient = true)
currentNode
handles
toolbar
imageBounds = [];
end
... |
function [] = bigTrainTestPrepare_manyfiles(DataDir,files,blocksize,test_hoproportion,val_hoproportion)
% Prepare bigarrays for training, validation and test set
% INPUT:
% -DataDir = directory cointaing as many .mat files as the number of classes
% Each file must contain the variables:
% - x, the d x n_i inpu... |
function [output] = optim_func_evsi1(m1, all_mods, mod_prob_all, B,...
c1, c2, q, samp_postprob)
% DESCRIPTION: creates the function that is optimized in EVSI - 1st term
% investment
% TYPE: function
% AUTHORS: Payal Bal
% INPUTS:
% OUTPUTS:
mod_species_all = NaN([1,size(all_mods,1)]);
for i = 1:size(all_m... |
classdef ThreeDWalkerSplayState < ThreeDWalkerState
% ThreeDWalkerSplayState wrapper around the state of a ThreeDWalkerSplay
methods (Static)
function [] = setQsUsAndTrigInCurrentFunctionFromState(state)
x = state;
ws = 'caller';
i = 1;
assignin(ws, 'q1', x... |
function heatmap(ax, pac)
assert__contains_fields( pac.labels, {'regions', 'amplitude_range', 'phase_range'} );
assert( numel(pac('regions')) == 1, 'There can only be one region.' );
assert( ax.isvalid, 'The axis is deleted.' );
phase_ranges = pac( 'phase_range' );
amp_ranges = pac( 'amplitude_range' );
data = nan(... |
function [ dicomDb ] = addDicomObjToDatabase( dicomDb, files )
%ADDDICOMOBJTODATABASE [please add info on me here :<]
if isempty(files)
return;
end
if ~dicomDb.fileAvailableInDb(files{1})
dicomDb = dicomDb.parseDicomObj(DicomObj(files{1}, false));
end
files(1) = [];
dic... |
function [pupil,eyeX,eyeY,ball,info,dball,movement_angle,movement,velocity,deyeX,deyeY,dmovement_angle,dmovement,dvelocity]=main_combineEyeDb(db,save_data)
addpath('\\zserver.cortexlab.net\Code\2photonPipeline');
addpath('\\zserver.cortexlab.net\Code\Matteobox');
addpath('\\zserver.cortexlab.net\Code\Neuropil Correct... |
%% Rearranges given row vector in a cell array of matrices corresponding to a
%% network with given architecture.
%%
%% weights - row vector
%% architecure - row vector defining the network architecture: each element of
%% this row is the number of units in corresp. layer
%% orientation - "v" or "h" (ve... |
%% Implementation of the IRD algorithm in the following paper:
%%
%% 刘子昂, 蒋雪, 伍冬睿*, "基于池的无监督线性回归主动学习," 自动化学报, 2020.
%% LIU Zi-Ang, JIANG Xue, WU Dong-Rui. Unsupervised Pool-Based Active Learning for Linear Regression.
%% Acta Automatica Sinica, 2020.
%%
%% Or the English version here: https://arxiv.org/pdf/2001.0... |
function [count, xg, yg]=point_count_image(x, y, x0, y0)
if length(x0)==1
xr=round_to(range(x), x0);
x0=[xr(1)-x0 x0 xr(2)+x0];
end
if length(y0)==1
yr=round_to(range(y), y0);
y0=[yr(1)-y0 y0 yr(2)+y0];
end
ind_x=ceil((x-x0(1))/x0(2));
ind_y=ceil((y-y0(1))/y0(2));
xg=x0(2)+(x0(1):x0(2):x0(3));
yg=y0... |
function error = costfunc_M2a(p,p_prev,p0,u,x0,tspan,data,gene_data,R,m)
% -- compute model simulation
[t,x_sim,j_sim,y_sim] = simulate_model(tspan,x0,p,p0,u,m);
p_diff = ( (p-p_prev) ./ p0) / (t(end)-t(1));
p_diff = p_diff(1:length(p));
mindiff = 1e-6;
pdreg = [
sqrt(1/3) * p_diff(14) ./ (max([gene_data.l... |
function rdm=cal_rdm2(Mi,Mt)
data=Mi./sqrt(sum(Mi.^2,1)) - Mt./sqrt(sum(Mt.^2,1));
rdm=sqrt(sum(data.^2,1));
end |
img = imread('shuiyin123.jpg');
for i = 1:size(img,1)
for j = 1:size(img,2)
if img(i,j) == 0
img(i,j) = 0;
else
img(i,j) = 255;
end
end
end
img = dicomread(filepath);%读取图片
img=double(img); %将灰度级映射到0~255
low=min(min(img));
high=max(max(im... |
function [benchmarks testmarks] = polypredict2(arch, nsize)
% aprediction: MATLAB script for testing
% bm[1] -> bmname
% bm[2] -> bmcolor
% bm[3] -> bmerror
% bm[4] -> errstats
% bm[5] -> pcnterr
% bm[6] -> h
% bm[7] -> p
% bm[8] -> ci
% bm[9] -> power
% bm[10] -> powerhat
benchmarks={'bzip2' 'b'; ...
... |
clc;
close all;
clear;
dataset=load('../data/digit.mat');
train_set=dataset.train;
% get the sample number of train_set
train_sample_num = size(train_set, 2);
test_set=dataset.test;
% get the sample number of test_set
test_sample_num = size(test_set, 2);
%change the train image into a column vector of 28*28=784 di... |
function im2 = rotateImage( im, theta )
%ROTATEIMAGE Rotates image about its centre
%
% im2 = rotateImage( im, theta) where im is the
% image to be rotated and theta is the rotation
% angle in degrees. Uses nearest neighbour
% interpolation.
%
% Hanif M. Ladak, 2014
% HML 15 OCT 2016 Tested on R2015+... |
function corrplot(x)
a=load(['trace' num2str(x)]);
subplot(211);
plot(a);
b=imread(['pic' num2str(x) '_0.jpg']);
subplot(212);
imagesc(b);
colorbar
end |
% This first comment appears when we type 'help functionName' in command.
% Remove a column of an array
A = [1:3;2:4];
disp(A);
A(:,2) = [];
disp(A);
% Create logic to replace numbers over 10 and under 0 to be Nan
A = [-10,-6,3,5,-8,11,6,10];
for i=1:length(A)
if A(i) < 0 || A(i) > 10;
A(i) = NaN;
end... |
%% Homework 2
% Minhyuk Nam (20150555)
% Date 02/04/2018
%% Random Matrix
clear all
A = [randperm(9, 3); randperm(9, 3); randperm(9, 3)]
a = sort(A(:));
temp = a(1);
b(1) = temp;
j = 2;
for i = 2 : 9
if temp == a(i)
continue;
else
b(j) = a(i);
j = j + 1;
end
... |
function trajectory = trajectory_generator
%trajectory_generator: generates the reference trajectory
% Detailed explanation goes here
% Declaration of variables
Nt = 1000; % nº of trajectory points
% Measured points:
m = [1.671, 1.672, 1.672, 1.672, 1.206, 1.206, 1.209, 1.674, 1.705, ...
1.203, 1.216,... |
function[val,g] = fquad(x,c,H,mtxmpy,data,D)
%FQUAD Evaluate quadratic function.
% val = FQUAD(x,c,H,mtxmpy,data,D) evaluates the quadratic
% function val = c'*x + .5*x'*D*MTX*D*x, where
% D is a diagonal matrix and MTX is defined by the
% matrix multiply routine 'mtxmpy' and 'data'.
%
% [val,g] = FQUAD... |
function output = ws(varargin)
global sim_params
% if there is no argument, we start the simulation without gui
output = -1;
if (nargin == 0)
% COMPILE %clc;
% COMPILE %initial_default;
% COMPILE %sim_params.gui_mode = 1;
% COMPILE %simgui;
% COMPILE %initial_gui;
% COMPILE %elseif(strcmpi(varargin{1}, 'guioff'))
i... |
function retrain_interpolators()
% Take back the global vars
global interpolators;
global training_data;
global logfile;
fprintf(logfile,'\nretrain_interpolators()\n');
% Brutally retrain all the interpolators cells, actually a cellarray function should be used here!
[I, J] = size(interpolators);
for i = 1:I
for... |
function [tmpData] = xxxReturn2Image(data,index,sz)
% What is the size of the new images?
newSz = [sz(1) sz(2) size(data,2)];
% Full size empty matrix
tmpData = NaN([newSz(1)*newSz(2) newSz(3)]);
% Restore to original location
tmpData(index,:) = data;
% Reshape
tmpData = reshape(tmpData,newSz);
end
%%%%%%%%%%%%%%%... |
function allinds = getSpecificIndices(result, fieldname)
design = getfield(result,fieldname);
fact = fullfact([length(design.orientations),length(design.sizes),length(design.contrasts),...
length(design.spfreqs),length(design.light),length(design.tfreqs)]);
for i = 1:size(fact,1)
conds(i,:) = [design.orienta... |
%% 1: 適当にIMCL0%のサンプルのRFデータを呼び出す.
legendInfo = cell(1,10);
figure;hold on
for ii = 2:2:20
loadfilename = sprintf("H:/data/kwave/result/2018_10_15_realisticScatter_variousIMCL_Correct/case1_IMCL%0.1f/rfdata.mat",ii/10);
load(loadfilename);
plot(rfdata(:,150,50));
legendInfo{ii/2} = sprintf('IMCL = %0.1f ... |
%
% Misplaced tiles for puzzle T
%
function [Mt,lev] = trees_mt(T)
global np N1 Tg
n = size(T,2);
Mt = zeros(1,n);
for k = 1:n
D = T{k};
for i = 1:3
for j = 1:3
if D(i,j) ~= 0
if D(i,j) ~= Tg(i,j)
Mt(k) = Mt(k) + 1;
end
end
... |
%Damped Oscillatory Motion using Euler-Cromer Technique
clear all;
%Values provided
m = 0.2; %mass of object
k = 0.45; %spring constant
c = 0.01; %Damping coefficient
%Initial values
v(1) = 0; %velocity
x(1) = 0.2; %displacement
t(1) = 0; %time
%Calculate period of the spring
period = 2*pi*sqrt(m/k);
disp('Period o... |
%% ========= constructing the experiment "cocktail party problem." ========
% MIT Press, September 2004. [modified by me]
% Copyright: 2005, JV Stone, Psychology Department, Sheffield University, Sheffield, England.
% Basic Bell-Sejnowski ICA algorithm demonstrated on 2 speech signals.
%------------------------... |
function xf = compute_landing_distance(vi, theta)
%%%%%%%%%%%%%%%%%%%%%
% Naoki Tominaga
% u0876779
% ME EN 1010 Lab Section #5
% HW#6 and compute_landing_distance.m
% 3/7/15
% compute_landing_distance - computes the final horizontal landing distance
% when it hits the ground at y = 0
% inputs - vi (initial velocity)
... |
function load_modhdrs(modfile)
global PARAMS
modhdrs = load(modfile);
modhdrs = modhdrs.modhdrs;
% loop through each of the messed up entries
for i = 1:size(modhdrs, 1)
modI = modhdrs(i, 2);
if modI
PARAMS.head.dirlist(modI, :) = [PARAMS.head.dirlist(modI, 1),...
modhdrs(i, 10:16), PARAM... |
function mockdata_plots_2
% Plot results of mockdata runs for state space IPM manuscript
% Fig 1a: Plot estimated values of F for 'baseline' runs
figure(1)
clf
set(gcf,'units','cent','position',[10,10,12.9 18])
% ------------------------------------------------------
% Loop over 'true' values then 10 runs in each ... |
function [ jointAngles ] = gaitController(trajectory, hexXY, direction, num)
% Gait Controller for forward, backward, left, and right walking steps
%
% Simon Kalouche
% Biorobotics Lab
% extract info from input paramters and assign to appropriate variables
x1 = trajectory(1,:);
x2 = trajectory(2,:);
y1 = traj... |
% Turn off all non-essential processes before running!!!
% Clear the workspace and the screen
%% Lab Streaming Layer Initialization
% Initialization of the lab streaming layer should occur before the
% Psychtoolbox opens a screen. That way, LabRecorder can be initialized.
%%% Set up LSL for event markers
lib_lsl_path... |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% author:夏华林
% data:August 11, 2014
% version:1.0
%
% Copyright notice:
% Free use of the Midge Classify is
% permitted under the guidelines and
% in accordance with the most curre... |
function yes = hasObject(I,removedRegion)
[height,width,~] = size(I);
yes = 0;
for h = 1:1:height
for w = 1:1:width
x = I(h,w,4); y = I(h,w,5);
if removedRegion(x,y) == 1
yes = 1;
break
end
if yes ==1
bre... |
function [projectedVs, Vquality, err2sigma] = createAveragedModel(floatScan, refScan, averageResults)
%% https://github.com/psapirstein/mesh-comparing
% This code is distributed under an Apache License 2.0
% Author: Philip Sapirstein, UNL
% However, see below the simplied code for triangle-ray intersection
% adapted fr... |
n_rats = 6;
counter = 1;
step2_port_times = [];
outcome_port_times = [];
init_port_times = [];
choice_port_times = [];
period_switches = [];
for rat_i = 1:n_rats
loaded = load(fullfile(files_path, 'preprocessed_data', 'opto_peh', ['opto_peh_rat_' num2str(rat_i)]));
peh = loaded.peh;
n_sessions = length(... |
function ASSIGN_hard_constraints()
% global params
% switch params.CASE_STUDY
% case 'EOS'
% ASSIGN_EOS_hard_constraints;
% case 'DECADAL'
% ASSIGN_Decadal_hard_constraints;
% end
end |
function flag = isLocalMax(patch)
patchCenter = (size(patch,1)+1)/2;
[rows,cols] = find(patch == max(patch(:)));
if(size(rows,1)>1)
flag = 0;
elseif(isequal([rows,cols],[patchCenter,patchCenter]))
flag = 1;
else
flag = 0;
end
end |
function dataOut = featuresClassic(I, labelMatrix, featureParams, featurePrep)
% function dataOut = featuresClassic(cs, fileNbr)
%
% featuresClassis is the high level feature extraction file. It created the
% texton map from INPUT image I and then extract histograms at locations
% specified by INPUT labelMatrix. INPUT... |
function [m_CTHomog,m_SigmaHomog,hvar_newMacro,aux_varMacro] = ...
f_RMap_MECohesivo(...
m_IDefMacroReg,m_IDefMacroLoc,m_sigmaHomog_old,hvar_oldMacro,aux_varMacro,...
e_DatMatSetMacro,condBif,e_VGMacro)
%Se recupera variables micro
xx = e_DatMatSetMacro.xx;
omegaMicro = e_DatMatSetMacro.omegaMi... |
function queryCircle(year, window,windowLength,dow, eigenVec, normData,basePath)
%% retrive and display information about one specific circle plot
%
% Setting user-specified inputs to default if not specified
if nargin < 6 || isempty(normData);
normData=false;
end
if normData
folderName=sprintf('%s/... |
function oraw=filterlx(iraw,width,window)
% -------------------------------------------------------------------------
% kspace_filter(iraw) generates the 3D filtered kspace image. Only filter
% function is a fermi window. The input complex kspace dataset is
% multiplied by the 3D fermi window.
%
% INPUT: "iraw" ... |
function k = radialTRAJ(angles,Kdim,distribution,varargin)
% Tom Bruijnen - University Medical Center Utrecht - 201609
% Set parameters from input
dim=num2cell(Kdim);
[ns,nl,nz,~,ndyn]=deal(dim{:});
if strcmpi(distribution,'uniform')
% Calculate sampling point on horizontal spoke
d_x=-1/(ns);
... |
function PSS = generatePSS_2(sd)
PSS = zeros(10,1,10);
for s = 1:10
for s_prime = 1:10
for a = 1:10
PSS(s,s_prime,a)= getP(s+a-1,s_prime,sd);
end
end
end |
%% BME 790.01F13 Engineering Programming and Signal Processing
%% Homework 4 Kanishk Asthana ka112@duke.edu
%% Part 4
%% (a)
clear;
close all;
clf;
%Loading Image;
load('Austin.mat');
figure(1);
subplot(2,2,1);
%Plotting Image in First Row
imshow(IM);
title('Original Image');
subplot(2,2,3);
%Taking 2D fft of image
imf... |
function ret = OME_tif2Omero_Image(factory,filename)
% Copyright (C) 2013 Imperial College London.
% All rights reserved.
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of t... |
function [fft_xy] = fft_ptclshape(xx,yy,mP,NLi)
y_bar = mP(2);
x_bar = mP(1);
th = linspace(0,2*pi,500);
T = th(2)-th(1);
Fs = 1/T;
lx = length(xx);
jf = 0:lx-1;
kArr = [1:20];
YF = fft(yy);
P2 = abs(YF/lx);
P1 = P2(1:lx/2+1);
P1(2:end-1) = 2*P1(2:end-1);... |
clear all; close all;
global ACFOISI;
global FS;
ACFOISI = 1;
FS = 10e6;
h = rrcosfilter(0.3, 1e6, 20); |
close all; clear all;
f=fopen('test14_45w.dat','rb');
D=fread(f,[4, inf],'int16');
fclose(f);
T = D.';
data = T(:,4);
signal = data(1:800);
aquisitionFrequency = 500;
cutFrequency = 30;
[px1, w1] = pwelch(signal);
f1 = (w1)*aquisitionFrequency/2/pi;
[b,a] = butter(20, cutFrequency/(aquisitionFrequency/... |
clear; clc; close all;
%
% Consider n coupled second order dynamics
% d^2 xi/dt^2 = -gamma dxi/dt + SUM_j A(i,j) * (x(j)-x(i)) + Pi;
%
% To use ode45, we convert the n second order equations 2n first order equations
% Dimension of the system
n =10;
% get network and power
[A, P] = symmetricNetwork('star')
%A = A-... |
% defaultParams - Inicializa os valores por defecto da estructura params.
function params= defaultParams(sze)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Tamaño da imaxe
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
params.sze=sze;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Parametro... |
function [U] = normal_to_subspace(normal)
A = randn(3);
A(:,1) = normal;
[U, ~] = qr(A);
U(:,1) = normal;
end |
%% recover_backup_db.m
function [] = recover_backup_db(filename)
load(filename)
sciences = NUM_sciences;
costs = NUM_costs;
archs = NUM_archs;
narchs = length(archs);
for j = 1:narchs
good_pack_archs{j}.arch = archs{j};
good_pack_archs{j}.science = sciences(j);
good_pack_archs{j}.cost = costs(j);
end
weigh... |
%% Deep symbolic tricks
% File: deep_symbolic_tricks.m
%
% Author: Peter Polcz <ppolcz@gmail.com>
%
% Created on 2017. November 08.
%
% Declare some symbolic scalar valued function
%%
syms t x y z real
n = 2;
m = 3;
V = sym(zeros(2,3));
for i = 1:n
for j = 1:m
V(i,j) = str2sym(sprintf('V%d%d(t,x,y)',i... |
%clear all
load 'protocolStruct20140717_15-46.mat';
a = tic;
for j = 1:100
for i = 1:length(protocolStruct.stim)
abc = protocolStruct.stim(i).matCell;
%abc = protocolStruct.stim(1).matCell;
patVectorMatrix = convertPatternMatrixMex1(abc);
end
end
time = toc(a)/(144*31*100)
|
function s = RSADigitalSig(P,d,n)
% s = RSADigitalSig(P,d,n)
s = FastExp(P,d,n);
|
%Sistemas de Ecuaciones no lineales 2x2
%Método de Punto Fijo Multivariado
%Luis Mario Urrea Murillo
%Codigo 4072011 Universidad Cooperativa de Coolombia
function [iter,x,ea] = puntofijomultivariado2x2
syms x1 x2 %sistema para dos ecuaciones
x0=input('Digite f(x0)=');%valores iniciales de x1, x2 en un vector fila
tol=... |
function [tout, xout, yout, vxout, vyout, rmin, rmax] = VerletK(t0, tk, x0, y0, vx0, vy0, h)
t = 0;
x = x0;
y = y0;
vx = vx0;
vy = vy0;
tout(1) = t0;
xout(1) = x0;
yout(1) = y0;
vxout(1) = vx0;
vyout(1) = vy0;
GM = 4*pi^2;
n = floor((tk-t0)/h);
rmin = sqrt(x^2+y^2);
for i = 1:n
r = sqrt(x^2+y^2);
vxMid = vx+(h*(-(GM/... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.