text stringlengths 8 6.12M |
|---|
function [err] = compareSolution(n)
fa = fopen("a.m", "r");
fb = fopen("b.m", "r");
fc = fopen("c.m", "r");
A = fread(fa, [n,n], "double");
B = fread(fb, [n,n], "double");
C = fread(fc, [n,n], "double");
err = max(max(abs(A'*B' - C')));
end
|
% Initialisation
cps = {};
log_cps = {};
for t = [1:4]
% define cps values
for i = [1:3]
cps{i}.p = i*[10,10,10]+[t,t,t]/3;
cps{i}.w = 30*i*t;
cps{i}.prio = i;
% log data works
log_cps.psum(t,i) = sum(cps{i}.p);
log_cps.w(t,i) = cps{i}.w;
log_cps.prio(t,i) = cps{i}.prio;
%... |
%% INFO
%Use of SICK LMS 111
%Daryl W. Bennett ~dwbennet@mtu.edu ~kd8bny@gmail.com
%Purpose: Function to get status of LMS
%TODO: Make function
%Notes: All binary (Could use HEX in future)
%Command Structure:
%[Start text][MSG length][CMD Type][SPC][CMD][CHKSUM]
%% Setup
clc,clear
%Delclare telegram. See: INFO/comma... |
function [outvet1 outvet2] = sameLength(invet1, invet2)
% sameLength - make two vectors have the same length equals to the small
%
% Syntax: [vet1 vet2] = sameLength(vet1, vet2)
%
% Inputs:
% invet1 - first vector
% invet2 - second vector
%
% Outputs:
% outvet1 - first vector
% outvet2 - second vector
%
% ... |
function [hist_prec,hist_prec_mean,mean_stop_num,stop_step,total_step,parms_inner] = get_early_stop_step2(parms)
if nargin == 0
parms = struct();
end
hist_prec = zeros(5,101);
stop_step = zeros(1,5);
total_step = zeros(1,5);
clear inited;
init
clear do_force do_plot
parms_inner = parms;
%z
if ~isfield(parms_i... |
%fundamental constants
kB=1.380e-16;%Boltzmann's constant in erg/K
NA=6.022e23;%Avogadro's number
c=2.9979e10;%speed of light in cm/s
muB=9.2741e-21;%Bohr magneton in erg/G
muN=5.051e-24;%nuclear magneton in erg/G
hP=6.6262e-27;%Planck's constant in erg/Hz
hbar=hP/(2*pi);%in erg s
re=2.816e-13;%classical... |
function stan_audio_compute_sdi_all_consensus()
[~,dirs]=stan_preflight();
listing=robofinch_dir_recurse(fullfile(dirs.agg_dir,dirs.sdi_dir,'analysis'),'mic_data.mat');
for i=1:length(listing)
disp([listing(i).name]);
[pathname,filename,ext]=fileparts(listing(i).name);
if exist(fullfile(pathname,'sdi_consensu... |
function [x]=s_extract_triu(X,methodid)
if nargin<2, methodid=3; end
switch methodid
case 1
error('Do not us: output vector element order differs from other methods.')
n=size(X,1);
x=[];
for k=1:n-1
x=[x;diag(X,k)];
end
case 2
mask = bsxfun(@lt,[1:si... |
clear; clc; close all;
load('cellLR.mat');
num_stimuli = 96;
frame_stack = zeros(num_stimuli, 3);
for i=1:num_stimuli
frame_stack(i, :) = cellL{i}(1,:,end); %first frame for first point (point, dims, time_frame)
end |
function [sum_err,num_ite,B,C] = delta_kmeans(A,k,itor,tor_err)
[IDX,C]=kmeans(A',k);
B = zeros(size(A,1),k);
for i=1:size(IDX)
B(i,IDX(i))=1;
end
B = B';
C = C';
Err = zeros(1,itor);
Err(1) = sum(sum((A-C*B).^2));
for j=2:itor
B=B.*((C'*A)./(C'*C*B));
C=C.*((A*B')./(C*B*B'));
Err(j) = sum(sum((A-C*B).^2))... |
% visualize
u_plan = plan(world, struct('p', 0.1, 'f', @(n,m) n), 0);
mat = world.r;
imagesc(-mat); %# Create a colored plot of the matrix values
colormap(flipud(gray)); %# Change the colormap to gray (so higher values are
%# black and lower values are white)
textStr... |
function parCommTrain(trainMgr)
% PARCOMMTRAIN Uses the training manager to train an agent in parallel
% using the comm interface
% Revised: 10-26-2018
% Copyright 2018 The MathWorks, Inc.
% extract the agent, env, and training options from the train mgr
agent = trainMgr.Agent;
env = trainMgr.Environment;
trainingOp... |
function [x,y] = NoisyImpulseResponse(liblength,hitspace,hitpeak,C,B)
% C - impulse noise level
% B - response noise level
% liblength - signal length (library length)
% hitspace - spacing for impulses
% hitpeak - impulse peak
% build impulse signal
hititer = 0;
x = randn(1,liblength).*C;
x(2) = hitpeak;
for xiter = 2... |
function map = linear_beltrami_solver(v,f,mu,landmark,target)
% Linear Beltrami solver.
%
% If you use this code in your own work, please cite the following paper:
% [1] P. T. Choi, K. C. Lam, and L. M. Lui,
% "FLASH: Fast Landmark Aligned Spherical Harmonic Parameterization for Genus-0 Closed Brain Surfaces... |
function [pathL,goalf] = BFS_Expansion_AVM( Graph, source, goal, value )
%BFS_Expansion BFS of free spaces searching for frontier spaces along
%levels
% Approach:
% While frontier not found
% Expand w/ dir Matrix -> delete u, add four dir nodes if possible
% If frontier is found
% Record ad... |
function [interpMask] = morph_binary(mask1,mask2,n)
% MORPH_BINARY takes two 2D binary images and "morphs" one binary mask
% into the other (with n intervening steps) using interpolation. This
% results in a 3D binary output composed of mask1, n interpolated slices,
% and mask2. This function may be useful when attemp... |
function [y,isterm,dir ] = option_fun_var_both_on(t,x)
% option function to start treatment on variance inclusive model when mean
% and variance get highenough. event marked by change in y value from -1 to
% 1
%set global variables
global beta mu_M D_M psi1 MT VT T_start
dx_m=@(t,x)metapop(t,x);
% if trea... |
function [ u1, u2 ] = controller(~, state, des_state, params)
%CONTROLLER Controller for the planar quadrotor
%
% state: The current state of the robot with the following fields:
% state.pos = [y; z], state.vel = [y_dot; z_dot], state.rot = [phi],
% state.omega = [phi_dot]
%
% des_state: The desired states are... |
%CNpRCL.m
% PARALLEL RCL CIRCUIT
% Finite Difference Method for PARALLEL RCL circuit analysis
% Voltage inputs: step function OFF/ON or sinusoidal
% Calls the function arrow.m to draw arrows
% Ian Cooper
% email: ian.cooper@sydney.edu.au
% School of Physics, University of Sydney
% DOING PHYSICS WITH MATLAB
% ... |
function [ point ] = FindShadowAndLightBorder( line )
%FindShadowAndLightBorder Summary of this function goes here
% Detailed explanation goes here
%dl=grad(line);
%znajdowanie extremów
k=0;
extremum=zeros(80,3);
for i=2:length(line)-1
if line(i-1)>line(i) && line(i+1)>line(i) %minimum
k=k+1;
ext... |
%---------------
% Finds sdist, pt_left, pt_right
%---------------
lineseg = [spos, spos_new];
botpos_mat = repmat(spos, length(pad_map_lines), 1); % (repeat matrix) preallocate for speed
% Find the intersection points and the particular map lines being intersected.
bumps = intersection(lineseg, pad_map_lines);
dis... |
function [ bcVector ] = boxCox( inputVec, lambda )
%performs the boxcox transform on an inputVec
bcVector = (inputVec.^lambda - 1)/lambda;
mBc = mean(bcVector);
stdBC = std(bcVector);
bcVector = (bcVector - mBc)/stdBC;
end
|
im = imread('image.tiff');
figure,imshow(im);
binary = toBinaryImage(im);
figure,imshow(binary);
ht2x2 = halftone2x2(im);
figure,imshow(ht2x2);
ht3x3 = halftone3x3(im);
figure,imshow(ht3x3);
|
function [ data ] = data_gen_all_neighborhood_orthogonal(alph ,fun,Net,Mesh,Ainv ,b, remove_duplon )
% Generate data for a given mesh all neighborhood take information of all
% the three neighborhood triangle. The data is generate to work is the
% location detection task.
% remove_duplon (bool): true to remove similar ... |
function obj = update( obj )
%UPDATE Summary of this function goes here
% Detailed explanation goes here
a=2-obj.it*((2)/obj.MaxIt);
Wolves.Position=[];
Wolves.Cost=[];
Wolves = repmat(Wolves,obj.GreyWolves_num,1);
for i=1:obj.GreyWolves_num
rep2 = repmat(obj.empty_particle,0,1);
rep3 = repmat(ob... |
function dir = path()
%path - Return the full directory to the ejovo.golden.constants mat file
pkgDir = ejovo.fn.getPkgDir;
if ispc
delim = '\';
else
delim = '/';
end
dir = strcat(pkgDir, '+golden', delim, 'constants.mat');
end
|
%% Exakt lösning av N
h=.01;
t=0:h:5;
N=exp(-t);
plot(t,N);
%% Euler framåt
NE=zeros(size(t));
NE(1)=1;
for i=2:length(t)
NE(i)=NE(i-1)-h*NE(i-1);
end
hold off
plot(t,NE);
hold on
plot(t,N,'m');
shg |
function d = norma(x)
% NORMA - Calcula la norma (o longitud) de un vector o conjunto de vectores.
%
% d = norma(x)
% Copyright (c) Pedro L. Galindo (1998)
if size(x,1)==1,
x=x';
end;
d=sqrt(sum(x.*x)); |
function int = addInterf(sig, JtoS, intType, int_f, fs)
if(strcmp(intType,'CW'))
% i.e. narrowband
int = exp(1j*2*pi*int_f*(0:length(sig)-1)./fs);
elseif(strcmp(intType,'FiltNoise'))
% error('Filtered Noise interferer not implemented');
Fs = 100;
d = fdesign.lowpass('Fp,Fst,Ap,Ast',6,10,0.5,40... |
% List of relative directories (relative to install.m's location)
folders = ["general", "plotting", "system", "CLI", "string_manipulation", "search"];
% Find out where 'install.m' is saved
file_path = mfilename('fullpath'); % Get full path to this file
if ismac || isunix
trim_idx = find(file_path=='/', 1, 'last'); % ... |
%clear all variables
clear all;
%reset the RNG to default
rng('default');
%start parallel processing
parpool
%set the constant, a:
a=0;
%set the anonymous function to maximize
f = @(x) sin(x)+0.01*(x-a).^2;
fplot(f,[-5*pi,5*pi]);
%set the options
%1. The algorithm will be quasi-newton (this is because the
% d... |
function [] = mixtureOfGaussians()
% 10 Data Blocks
D = cell(10, 1);
% 10 Label Blocks
L = cell(10, 1);
% Initialize blocks.
for i = 1:10
dataFileName = strcat('data/data', strcat(int2str(i), '.csv'));
labelsFileName = strcat('data/labels', strcat(int2str(i), '.csv'));
D{i} = csvread(dataFileName);
L{i} = csvr... |
% parameters setup for dx=(A x +B xx + C xxx) dt +s dw1 +sigma dw2
L=100;
Domain = 256;
N_window = 16;
N_slow = 16;
A = ones(N_slow, 3); %paramenters for the one-multiplication part
B = ones(N_slow, 6); %paramenters for the two-multiplication part
C = ones(N_slow, 9); %paramenters for the three-multiplication part
... |
function derCoeff = findDerivativeCoeff(n, r)
derCoeff = zeros(r+1, n+1);
tempC = ones(1, n+1); % constant
derCoeff(1, :) = tempC;
for i=1 : r % for derivatives 1 to k
tempC = polyder(tempC);
derCoeff(i+1, :) = [tempC zeros(1, n + 1 - length(tempC))];
end
end |
%function verify(varargin)
%
% Runs verification cases for selected reactors
%
% Examples:
%
% verify('f1');
% verify('f1','f3');
% verify('f1','test') Only runs the initilazation of matstab
% to test if all files etc are OK
%
function verify(varargin)
CM_HOME=['/cm'];
t0=cputime;
if nargin==0
... |
load('data3.mat')
arModel = ar(data(:,1),2); |
function [LL likey output] = single_trial35musc(param, mydata, varargin)
% this version scales the sensory noise with the magnitude of the clicks,
% June 2012, BWB
pairs = { ...
'dx' 0.25 ; ...
'dt' 0.02 ; ...
'bo' [] ; ...
'P_init' [] ; ...
'W_i' ... |
function data_output = rearrange_data (data_phase, options, system)
time_res = system.time_resolutions{options.Time_Resolution,2};
data_points = round((size(data_phase,1)-1)/time_res);
data_mean = reshape(data_phase(1:end-1,:),time_res,size(data_phase,2),[]);
data_min = squeeze(min(data_mean))';
data_max = squeeze(ma... |
function generate_lists(vars)
disp('====== Generating List Files ======');
fprintf('Writing H0-H9 to [%s]...\n', vars.word_list);
f_wl = safefopen(vars.word_list, 'w');
for i = 0:9
fprintf(f_wl, 'H%d\n', i);
end
fprintf(f_wl, 'SIL\n');
% fprintf(f_wl, 'SP\n');
disp('done.');
% generate phone list
... |
%%CDCF
clear;
parameter_initialization_CDCF;
fai_cu=0.5;
stepsize=1;
mem_area=.1:.1:.4;
areasize=.1;
for i_fai=1:length(fai_cu)
volume_ratio=fai_cu(i_fai);
fai=volume_ratio;
f_f=1;%.11:.1:.9;
c_d0=35;
c_f0=0.1;
o_p_power=0.5*van_coe*(c_d0-c_f0);
max_deltaP1=2*o_p_power;
deltaP1=1:step... |
function pdfplotm(datalist)
linest={'b','r','g','m','c','k','g','y','r','m','c','b','k','g','y','r'};
mlinest={'.','o','x','+','*','s','d','v','^','<','>','p','h'};
h2=[];
hold on
for k=1:length(datalist)
[f,xi] = ksdensity(datalist{k});
%h=pdfplot(datalist{k});
%set(h,'FaceColor','none','EdgeColor',[0... |
function images = pick_frames(video_path)
images = {};
video = cv.VideoCapture(video_path);
while video.grab()
image = video.retrieve();
imshow(image)
should_save = input('save? ', 's');
if should_save == 'y'
images{end + 1} = image;
end
for i = 1 : 5
video.grab();
end
... |
function [E,Theta] = RegressionFun( X,y,m,Alpha)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
n=length(X(1,:));
Theta=zeros(n,1);
k=1;
[E(k),X,Y]=CostFunLinear( X,y,Theta,m);
R=1;
while R==1
Alpha=Alpha*1;
Theta=Theta-(Alpha/m)*X'*(X*Theta-Y);
k=k+1;
E(k)=(1/(2*m)... |
% Produced by CVXGEN, 2018-03-27 07:35:59 -0400.
% CVXGEN is Copyright (C) 2006-2017 Jacob Mattingley, jem@cvxgen.com.
% The code in this file is Copyright (C) 2006-2017 Jacob Mattingley.
% CVXGEN, or solvers produced by CVXGEN, cannot be used for commercial
% applications without prior written permission from Jacob Ma... |
<<<<<<< HEAD
function [SOUND_chan,VNO_chan,VALVE_chan ] = generate_single_SNT_stim_scan(Params)
% Generate a single SNT stimulation train
% param fields are
% SR sampling rate in Hz
SR = Params.SR;
samples_VNO_stim_duration = Params.VNO_stim_duration * SR;
%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%... |
clear all
close all
clc
global path_img path_save format_img;
% the tools used in algorithms are configured in the config_tool.m
run('config/config_tool');
clear all;
global path_img path_save format_img;
run('config/config_para');
format_img = 'jpg';
path_img = '~/dataset/dataset2014/dataset/baseline/office/inpu... |
function b= dcsol(x,y,d)
% compute the original solution without penalty function
[n,p]=size(x);
X=x-ones(n,1)*mean(x);
N=cov(X);
N1=sqrtm(N);
N2=inv(N1);
sX= X * N2;
options = optimset('Display','notify','Algorithm','active-set','MaxFunEvals',1e6,'MaxIter',1e6,'TolFun',1e-4,'TolX',1e-4,'LargeScale', 'off');
[WX,W1... |
%%
%
% Created May 28, 2014 by Patrick Knapp (Sandia National Laboratories)
function object = abelInvert(object,varargin)
% Default parameters
minTransmission = 1e-3;
method = 'TwoPoint';
% Parse variable inputs
if length(varargin)>1
for i = 1:length(varargin)
if strcmp(varargin{i},'method')
meth... |
%% Assignment II [Advanced Machine Learning]
%% kPCA example to determine the number of clusters.
%% Make sure you have added the path of ML_toolbox to your directory.
%
% [ High dimensional clusters ]
% You have to figure out the number of clusters present in the datasets by using kernel-PCA
clear all; close al... |
% hulls is a data of N rows, 4 or 6 columns
function hull = hullofHulls(hulls)
sets = length(hulls(:,1));
len = length(hulls(1,:));
hull = hulls(1,:);
if len <=6
for i = 1 : sets
if hulls(i,1) < hull(1)
hull(1) = hulls(i,1);
end
if hulls(i,2) > hull(2)
hull(2) = ... |
%CSI 700
%Comp Problem 4.6: QR Iteration
%J Schott
function [D,results] = qrit(A,errMin)
[m,n] = size(A);
results = zeros(100,2);
I = eye(n);
k =1;
err = errMin +1;
while ( err > errMin )
sig = A(n,n);
tmp = A-(sig*I);
[Q,R] = qr(tmp);
newA = (R*Q) + (sig*I);
A ... |
function recon_2D_ungated_SPGR_mSMS_low_rank_car_ph_resolved_ADMM_auto(para)
%--------------------------------------------------------------------------
% recon_2D_ungated_SPGR_mSMS_low_rank_car_ph_resolved_ADMM_auto(para)
%--------------------------------------------------------------------------
% Reconstruct CRI... |
fs = 48000;
ts = 1/fs;
sp = 240;
T = 12;
fade_win = 0.02;
arc = @(r, t) r * sin(acos(((ts:ts:t)/t-0.5)*2));
circ = @(r, t) [1; -1] * arc(r, t);
linD = @(deg, t) (ts:ts:t) * sp * tan(pi/180 * deg);
linP = @(y1, y2, t) y1 + (ts:ts:t) * (y2-y1)/t;
fit = @(s, T, f) [nan(size(f, 1), round(s/ts)), f, nan(size(f, 1), round... |
function [fsw_data, fsw_bgs, p_fit] = lock_fsw_scan_180807(instrs, CAL,...
center_frequencies, atten, V_cavity, side, fnamesuffix, fswconfig, isfit )
% lock detuning by VNA and FSW scan
% center_frequencies: frequencies to take data on
% CAL: fit info from e.g.: [CAL,F,v1sig,vx,wlsig] = piezo_scan_fit('bigPiece... |
clear all
close all
clc
addpath(genpath('6DayDataset'))
%%
% the only parameters to modify if the dataset changes are nd, nb, the name of
% the input files and the folder where to save the data
%
% the output are two file EEGyes.mat and EEGno.mat containing the signals
% corresponding to the yes/no answer and a file ... |
function [ v, z ] = model_eval( model_str, Mass, n, d, v, ha, mu, e )
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
if strcmp(model_str,'DrumShell')
[v, z] = DrumShell(Mass, n', d', v, ha, mu, e);
end
if strcmp(model_str,'whittaker')
[v, z] = whittaker(Mass, n', d', v, ha, mu... |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copyright 2012 Analog Devices, Inc.
%
% Licensed under the Apache License, Version 2.0 (the "License");
% you may not use this file except in compliance with the License.
% You may obtain a copy of the License at
%
% http:/... |
function p=calibrate(p)
%pds.eyelink.calibrate start eyelink calibration routines
% p = pds.eyelink.calibrate(p)
%
% Run basic eyelink calibration sequence, using pldaps to present stimuli (via PTB)
% and send/receive communication from Eyelink.
%
% [p] Pldaps structure (should be currently running/paused)
%
% Al... |
function result = RunSimulation(simParam);
odeOptions = simParam.simulator.odeOptions;
timeSpan = simParam.simulator.timeSpan;
initialCondition = simParam.simulator.initialCondition;
sol = ode45('ModelDynamics',timeSpan,initialCondition, odeOptions, simParam);
[state, debugResult] = deval( sol, timeSpan );
result.ti... |
function k = num_principal_component(S)
s = sum(sum(S));
k = 8;
for i = 1:size(S,1)
z = sum(sum(S(1:i,1:i)))/(s);
fprintf('variance retained :%f \n',z);
if z >= 0.99
if i < k
k = i;
end
end
end
fprintf('no. of principal components required is : %d \n',k);
end |
%Generiert eine zufällige Zahl zwischen mmin und max
function [random]=RandRange(min, max)
random = min + rand(1)*(max-min);
end |
function [fig_nums] = bode_plot(f,H,varargin)
% function fig_nums = bode_plot(f,H,varargin)
%
% funzione per generare un diagramma di Bode (modulo e fase)
%
% f: vettore di frequenze (colonna)
% H: vettore (colonna) funzione di trasferimento complesso (oppure due vettore, uno
% ampiezza e uno con fase in radianti, [... |
% Valuation of an European Call with the following properties:
% - Strike: 100
% - Valuation Date: 01/01/2021
% - Maturity: 01/01/2022
% - Subyacent Value: 100
% - Subyacent Volatility: 20 %
% - Interest Rate: 0%
% Is European so exercice can only be exercited at maturity (Last Step)
exerciceFunction = @(datetimeArra... |
% Andrew Brown Lab 3 Problem 3
clc
clear
%Print out bottles on the wall and total until you reach at least 75
clc
clear
clf
%Practice with a while loop
%Define given variables
totalSum=0;
n=10;
saveSums=zeros(1,length(n));
saveDays=zeros(1,length(n));
k=0;
%For loop counting from 1 to 10 going up
while totalSum<7... |
%MIT License
%Copyright (c) 2019 Sherman Lo
close all;
clearvars;
this = GlmSelectAicAbsNoFilterDeg30();
this.run();
this.printResults();
close all;
this = GlmSelectAicAbsNoFilterDeg120();
this.run();
this.printResults();
close all;
this = GlmSelectBicAbsNoFilterDeg30();
this.run();
this.printResults();
close all;
... |
function [pathname] = uigetfile_n_dir(start_path, dialog_title)
% Pick multiple directories and/or files
% Copyright (c) 2011, Peugas
% All rights reserved.
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are met:
%
% * Redis... |
function recall_task
global exp;
clear trial;
%% Define variables here during debugging
exp.subj = input('Subject ID: \n');
%% Prepare things
init_butterfly;
set_buffers_and_messages;
%% Add Cogent (MUST be an absolute path - relative paths do not stick after changing directory)
addpath(genpath('C:\Users\Amy\Deskto... |
function g = gconstDymPattern(parms)
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
oldInd = 0;
for i=1:parms.totalKnotNumber
if i==1
nRow = parms.ndof;
nCol = parms.totalVarNumber;
gI=nan( (nRow)*nCol,1);
gJ=nan( (n... |
function [exp_mean_t1,var_t1,autocorr_t1_t2,coef_autocorr_t3_t4] = simulacion(cantidad_muestras)
%SIMULACION EJERCICIO 1
% Cada Muestra tiene la forma [ x(pi/2)
% x(pi/4)
% x(pi)
% x(2*pi)]
%Devuelve el valor esperado en p... |
reset_data_analysis_environment
load('../data_tokamak/B_fields.mat', 'Bphi0')
crash_duration_ini=tau_cr
crash_duration=crash_duration_ini
XI0_INI=0.01
mbulk=mD
MAX_DELTA_RADIUS=0.1*ceil(10*max(rx_evol_lin))
TE_profile_radial_ini=interp1((0:Nradial-1)/(Nradial-1),TE_profile_interp_ini,rho_tor_scale);
TI_profile_radial_... |
function y=rastrigin(x)
y=20+x(1)^2+x(2)^2-10*(cos(2*pi*x(1))+cos(2*pi*x(2))); |
function [occ_cell_index occ_cell_member_count] = GetOccupiedCells( obj, pop )
GridIndices=[pop.GridIndex];
occ_cell_index=unique(GridIndices);
occ_cell_member_count=zeros(size(occ_cell_index));
m=numel(occ_cell_index);
for k=1:m
occ_cell_member_count(k)=sum(GridIndic... |
clear; clc;
% read images
S = imread('images\I\eAC8775.jpg');
I = rgb2gray(S);
% process images
X = imrotate(I, 5);
X = imcrop(X, [10.5 27 214 51]);
X = otsu(X);
subplot(2,1,1);imshow(S); title('eAC8775');
subplot(2,1,2);imshow(X);
|
function fig = scopegui()
% SCOPEGUI is GUI-part for oscilloscope SCOPE.M function
% This is the machine-generated representation of a Handle Graphics object
% and its children. Note that handle values may change when these objects
% are re-created. This may cause problems with any callbacks written to
% depend o... |
function [KeyName2Idx, Idx2KeyName] = get_keyname_index()
KeyName2Idx = containers.Map();
Idx2KeyName = {'r-ankle', 'r-knee', 'r-hip', 'l-hip', 'l-knee', ...
'l-ankle', 'pelvis', 'thorax', 'upper-neck', ...
'head-top', 'r-wrist', 'r-elbow', 'r-shoulder', ...
'l-shoulder', '... |
clear
clc
close all
%%
% CHIRP params
% ===================================
% ===== User-defined paramaters =====
% ===================================
%
spectrometer = 'Tecmag'; %'Tecmag' OR 'Kea'
magnet = 'PM25'; %'PM5' OR 'PM25'
datadir = 'C:\CommonData\TKM\MolecSievesWater\';
datafile = 'MSH2O_CHIRP_1_09SEP2017... |
% CLEANUPREGIONS Cleans up small segments in an image of segmented regions
%
% Usage: seg = cleanupregions(seg, areaThresh)
%
% Arguments: seg - A region segmented image, such as might be produced by a
% graph cut algorithm. All pixels in each region are labeled
% by an integer.
% ... |
%%
% Returns flat laser distributions on each half.
%
function [blueP, redP] = laserFlatHalvesBRO(args)
global trackingParams;
leftBP = args(1); % Left blue
rightBP = args(2); % Right blue
leftRP = args(3); % Left red
rightRP = args(4); % Right red
hystMM = 3; % mm
shiftMultiplier = .5;
xShi... |
function out = horzcat(varargin)
for w=1:nargin
if isa(varargin{w},'hderiv')
ndiff = size(varargin{w}(1).dV,2);
nvector = size(varargin{w}(1).dV,1);
ncol = size(varargin{w},1);
break
end
end
cont = 0;
for w=1:nargin
if isa(varargin{w},'hderiv')
for... |
function varargout = checkhistory(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @checkhistory_OpeningFcn, ...
'gui_OutputFcn', @checkhistory_OutputFcn, ... |
function F = stencilxgridfRVC(G, Stencil, center)
%------------------------------------------------------------------------------
% Multiplies gridfunction G with Stencil.
% Excess area is filled by Vertex-Centered (VC) Reflection across boundaries.
%
% Design and implementation by:
% Dr. Paul M. de Zeeuw <Paul.de.Zeeu... |
function bool = inbackground(bw, x1, x2)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% inbackground function identifies whether the connecting line of the point
% pair (x1,x2) is intersected with the clumped nuclei boundary bw
% Params:
% bw is the boundary points
% ... |
function normals = vertexNormal(vertices, faces)
%VERTEXNORMAL Compute normals to a mesh vertices.
%
% N = vertexNormal(V, F)
% Computes vertex normals of the mesh given by vertices V and F.
% V is a vertex array with 3 columns, F is either a NF-by-3 or NF-by-4
% index array, or a cell array with NF elem... |
function create_behavior_structs(behav_param_file_name,dir_param_file_name,solo_param_file_name,co_param_file_name)
load(behav_param_file_name)
load(dir_param_file_name)
data_dir_info=dir(cells_struct_dir);
%% for each cell
day_before=0;
for ii_cell =3:length(data_dir_info)
ii_cell
... |
%% 目的:使用Field II实现肺部的PW信号仿真
% 二维仿真,calc_h二维点扩散方程
% By Luoshutu
clear; clc;
%% 初始化
path(path,'D:/MATLAB/Field_II_ver_3_24_windows_gcc');
field_init;
%% 设置仿真起始
Start = 3; % 从中心频率为Start*e6开始仿真
Num = 1; % 仿真
% figure;
% hold on;
for cir_map = Start:Start + Num -1
%% 参数设置
f0 = cir_map*(1e6);
% f0 ... |
function colormapeditor(fig)
%COLORMAPEDITOR starts colormap editor ui
%
% When started the colormap editor displays the current figure's colormap
% as a strip of rectangluar cells. Nodes, displayed as rectangles(end
% nodes) or carrots below the strip, separate regions of uniform slope in
% R,G and B. The gr... |
function [motionVect, TSScomputations, avg_mad] = motionEstTSS(imgP, imgI, mbSize, p)
[row col] = size(imgI);
vectors = zeros(2,row*col/mbSize^2);
costs = ones(3, 3) * 65537;
computations = 0;
mins=[];
L = floor(log10(p+1)/log10(2));
stepMax = 2^(L-1);
mbCount = 1;
for i = 1 : mbSize : row-m... |
function [pen_info] = cdexp_age_get_pen_info(path,exp,pen_names)
%
%
%
%
%
%
%
num_pens = length(pen_names);
pen_info = struct();
for i = 1:num_pens,
% Read in all cell info from penetration, or get cellinfo if already exists.
if exist([path filesep exp filesep pen_names{i} filesep 'cellinfo.mat']... |
function Y=PFE(data,options)
[nSmp,nFea] = size(data);
T=zeros(nFea,options.d,nSmp);
% Label = unique(options.gnd);
% nLabel = length(Label);
W=zeros(nSmp,nSmp);
nei=zeros(nSmp,nSmp);
Nei=cell(1,nSmp);
Distance = EuDist2(data,[],0);
[sorted,index] = sort(Distance,2);
neighborhood = index(:,2:(1+options.k));
for i=1:nS... |
function numID = graph2numKor(graphemeKor)
numID = double(graphemeKor);
end |
function N = nDCG_wt_k(score_mat,true_mat,wts,K)
%{
Author: Yashoteja Prabhu ( yashoteja.prabhu@gmail.com )
%}
num_inst = size(score_mat,2);
num_lbl = size(score_mat,1);
wt_true_mat = spdiags(wts,0,num_lbl,num_lbl)*true_mat;
num = helper(score_mat,true_mat,wts,K);
den = helper(wt_true_mat,true_mat,wts,K);
N = ... |
% Paschen Graph
%% Constants
T = 300; % Temperature (K)
kb = 1.381e-23; % Boltzmann Constant
ri = 1.3e-11; % Radius of nitrogen ion (as air is mostly nitrogen)
L = pi*ri^2/(kb*T); % Sometimes called A
%% empirical constants
A = 10.95; % can use A = 112.5, or A = 10.95
B = 273.78;% can use ... |
function [ClusterNums, I, H] = clusterTrace(Traces, varargin)
%CLUSTETRACE Groups unkown traces by similarity
% Takes a set of traces (e.g. spectra) and tries to group them together
% based on their similarity. Does not try to fit peaks, so may be better
% for comparing spectra when number or location of peaks is... |
function residuoMax(x, n, A, b)
r = zeros(1, n);
for i = 1 : n
soma = 0;
for j = 1 : n
soma = soma + A(i,j) * x(j);
end
r(i) = abs(soma - b(i));
end
r = max(r);
end
|
function [adaptation] = adaptation_quantification(U,selectedCells,displayOpt)
if (nargin < 3), displayOpt = 'on'; end
willdisplay = ~(strcmp(displayOpt,'nodisplay') | strcmp(displayOpt,'n') ...
| strcmp(displayOpt,'off'));
if willdisplay
figure(80);clf
end
rc = numSubplots(numel(U));
%%
adaptation = cell(1,n... |
function R=x2R(x)
%Convert a 1 by 6 array representing the first two rows of a rotation
% matrix into a full 3 by 3 rotation matrix
r1 = x(1:3);
r2 = x(4:6);
r3 = cross(r1, r2);
r1 = r1 / norm(r1);
r2 = r2 / norm(r2);
r3 = r3 / norm(r3);
R = [r1; r2; r3];
if(1)
R(1,3) = -R(1,3);
R(2,1) = -R(2,1);... |
function [Res,Tang] = test_assembly(mat_size, iter )
%returns zero res. and Identity tangent.
% for testing the main script
switch iter
case 0
Res = ones(mat_size,1);
Tang = diag(ones(mat_size,1));
case 1
Res = zeros(mat_size,1);
Tang = diag(ones(mat_size,1));
otherwise
... |
function [newInd, newUserObj] = constraintHandle_demo(ind, userObj)
limit = userObj.threshold;
if (ind(1)+ind(3)~=limit)
if(ind(1)>limit)
ind(1)=limit;
ind(3)=0;
else
ind(3) = limit-ind(1);
end
end
newInd = ind;
newUserObj = userObj;
end |
function [ModelCla]=modelCla(newcla,clanum,modelsN,K)
% ModelCla=ones(modelsN,K).*(-1/(modelsN));
% for MCi=1:K
% MCtemp=find(newcla==MCi);
% ModelCla(MCtemp,MCi)=1/clanum(MCi,1)-1/(modelsN);
% end
ModelCla=zeros(modelsN,K);
for MCi=1:K
MCtemp=find(newcla==MCi);
Mo... |
tic; % to time how long it takes to run because this does take some time
%only does 1 subject at a time
for i = 10:20
name = num2str(i); % Subject
%sampleRate = 256; % sampling rate (needed for time conversion)
load(['EEG_subject0',name]); % Load EEG data
load(['seizureGT_subject0',name,'.mat']);
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.