text stringlengths 8 6.12M |
|---|
function [obstacle,obstacleNumber] = DefineObstacle2;
num = 0;
obstacleSize=50;%22;
num = num+1;
obstacle(num).corner = [2;2];
obstacle(num).size = [-20;20];
num = num+1;
obstacle(num).corner = [8;10];
obstacle(num).size = [20;20];
num = num+1;
obstacle(num).corner = [34;2];
obstacle(num).size = [20;20];
nu... |
function [train_accuracy, test_accuracy] = nnFinance(X, y, training_percent)
batch_size = 100;
total = size(X,1);
train_size = floor(total * training_percent /batch_size) * batch_size;
trainX = X(1:train_size,:);
trainy = y(1:train_size,:);
testX = X(train_size+1: end, :);
testy = y(train_size+1: end, :);
hidden_nod... |
function display_marker_data(data, marker)
hf = figure;
h_ax1 = subplot(3,1,1);
title(marker)
ylabel('pos (mm)')
draw_marker_line(h_ax1, data.markers, [marker '_X_mm'], 'color','r','linestyle','-')
draw_marker_line(h_ax1, data.markers, [marker '_Y_mm'], 'color','g','linestyle','-')
draw_marker_line(h_ax1, data.marker... |
function [meanReplacedData binCenters] = mean_inBins(data, binSize, varargin)
% [meanTrend binCenters] = mean_inBins(data, binSize, locations)
%
% ------
% Input:
% 1 i1
%
% Output:
% 1 o1
%
% ------
% potential improvments:
% ------
% Code Info:
% creation: 2014-08-17 by ShS -> shervin.safavi@gmail.com
%... |
data = load('boat_variables.mat');
info = load('boat_variables2.mat');
plot(data.ans(1,:), data.ans(2,:),'blue'); % compass
hold on;
plot(data.ans(1,:), data.ans(5,:),'black'); % est psi
hold on;
title('TITLEEEE');
xlabel('[s]');
ylabel('[deg]');
hold off;
|
function interpEfield(layer_set_num,nrn_pop_name,nrn_model_ver,Efield_solution,over_write)
%interpEfield Interpolates E-field at all neuron compartments of population
%
% interpEfield(layer_set_num,nrn_pop_name,nrn_model_ver,Efield_solution)
%
% Inputs
% ------
% layer_set_num : integer
% spe... |
function plotCircle3D(fig1,center,normal,radius,image_num)
%% to plot circles
figure(fig1);
% xlim([-90 -60 ]); ylim([600 620 ]); zlim([340 440])
% axis([-90 -60 600 620 340 440])
view(-25,7)
daspect([1 1 1]);
% axis equal
theta=0:0.1:2*pi;
v=null(normal);
points=repmat(center',1,size(theta,2))+radius*(v(:,1)*cos(the... |
clear;
clc;
%% Prepare the data
n_list=[100]; %list of n values to try
p=10;
time2list= zeros(length(n_list),1);
time_2list= zeros(length(n_list),1);
for j = 1:length(n_list) %go through all n values
n = n_list(j);
input.EPI = 1e-3;
input.n = n;
input.p = p;
x=zeros(p,1);
pos=unidrnd(p,160,1);
for i=1:numel(pos)
... |
function [StimPosEst,MidDist,SCorrFinal,CorrTime,DeltaTime,CorrMidDist] = VocLocalizer(varargin)
% Localize vocalizations in space using a microphone array
%
% Realignment: 29.9.2016 (Jesse/Bernhard)
% - We think the intended distance between the lower edges of the microphones was
% - Horizontal: 46cm, i.e. 23cm from... |
%this file update the model.
%Inputs: None
%Outputs: None.
function [ret]=UpdateMdl(Mdl_name,MFile_name)
try
disp(Mdl_name);
db = load_system(Mdl_name)
disp('Model loaded successfully');
evalin('base', MFile_name);
set_param(Mdl_name,'SimulationCommand','Update');
disp('Model upda... |
function [d]=snp_hapnucdiv(hap)
%SNP_HAPNUCDIV
%
%Syntax: [d]=snp_hapnucdiv(hap)
[numHap,sizHap,seqHap]=counthaplotype(hap);
p=sizHap./sum(sizHap);
d=0;
for i=1:numHap-1
for j=i+1:numHap
d=sum(seqHap(i,:)~=seqHap(j,:))./length(seqHap(j,:));
% d=pdist(seqHap([i j],:),'hamming');
... |
function [x, y] = randomizeModules(nodesCombined, specificConnections, typeOfConnection, list_modules, uniqueNodes)
%% Assign random nodes, with replacement, to each module. Same number assigned.
import java.util.*;
import java.lang.*;
newNodesCombined = cell(length(nodesCombined), 1);
%% Main code
%% Make copy, and fi... |
%%
%% plotting IV results - both:
%% One sample: two-stage IV probit
%% Two sample: MR Egger, weighted median, MBE
%%
%sens='-sensitivity';
sens='';
resDir=getenv('RES_DIR');
xonesample = dataset('file', strcat(resDir,'/results-21753/nervous-followup/nervous-results.csv'));
x = dataset('file', strcat(resDir,'/result... |
function [s] = genTriangle(amp,fo,symm,fs,samples)
%GENTRIANGLE genera una senal triangular cuyos parametros son
% amp => amplitud de la senal senoidal
% fo => frecuencia
% symm => simetria o punto donde cambia la pendiente (0,1)
% fs => frecuencia de muestreo
% samples => numero de muestras ... |
clf;
x= -0.2:0.1:0.2;
fid = fopen('data/typeIIIratio.txt');
[ratios] = fscanf(fid, '&%f ',[5,8])'
hold on;
for i = 1:2:7
plot (x, ratios (i,:), x, ratios (i+1,:));
endfor
#title ("sin(x) for x = -10:0.1:10");
xlabel ("displacement/gram increment");
ylabel ("Rati... |
for i=1:size(all_OF,1)
mkdir(sprintf('of_hoss/Ped2/Test/Test%03d',i))
for j=1:size(all_OF,2)
I = all_OF{i, j};
if ~isempty(I)
imwrite(I,sprintf('of_hoss/Ped2/Test/Test%03d/%3d.jpg',i,j));
end
end
end
of_root='of_hoss/Ped2/Test/';
of_out_root='of_hoss/Ped2/all_of/';
sample_c... |
function e = elem_data(e,str,fid)
%ELEM_DATA: decode the element data
% e = elem_data(e,t_id,str,fid)
%-------------------------------------------------------------------------------
% Author:
% Chang, Ho-Ping (also known as Peace Chang)
% National Synchrotron Radiation Research Center
% 101 Hsin-Ann Road, Hsinchu ... |
function INDEXES = MatchAlignments(TOP_SEQ,BOTTOM_SEQS,PROVIDED_ALIGNMENTS)
% MatchAlignments
% Matches a cell-array of pairwise alignments to a set of alignment
% sequences. This allows the submission of a batch of alignments and
% sequences and returning the indexes of the alignments which ma... |
function stackCoord(F)
% takes coords from specified layers in pixel and stack them in a single file in microns
% /!\ for z computation, highest value of 'layers' must correspond to first layer in nrrd
% (e.g. z = 20 corresponds to z = 0 µm)
segPath = F.dir('Segmentation');
coordinates = NaN(0,3); % 0 neu... |
function [postMeans, postCovInds, postCovs] = inferFALatents(faMdl, x, varargin)
% Given an FA model and observed data this function will infer the
% posterior distribution over latent states.
%
% Usage: [postMeans, postCovInds, postCovs] = inferFALatents(faMdl, x, varargin)
%
% Inputs:
%
% faMdl - A structure wit... |
n=10000;
instantan_summa = 0; I_obs_summa = 0; Gamma_I_summa = 0;
N = 50; %Värden över 25 verkar ge okej resultat.
D_star = 13927*70e5;
separation = D_star / N;
k_noll = 2*pi/650e-9;
L_star = 6.62237e17;
[x,y,M]=xy_source(N,D_star,separation);
for i = 1:n
fas_vekt=rand(M,1)*2*pi;
fas=repmat(fas_vekt,1,N);
... |
classdef Protease
%PROTEASE: An object storing the properties of the protease
%
% Syntax:
% protrulelocaldb = Protease.mklocaldb;
% protrule = protrulelocaldb(protshortname);
% protrulelocaldb.keys
%
% Input:
% protshortname: short name for the protease
%
% Output:
% ... |
% tp_bar_001.m
% Heat Conduction along a cylindrical bar
% S.I. units used unless otherwise stated
% Default value and unit are given in ()
% Ian Cooper School of Physics University of Sydney
% cooper@physics.usyd.edu.au
% http://www.physics.usyd.edu.au/teach_res/mp/optics/optics_home.htm
tic
close all
clear all
c... |
function [ error ] = mape( lGrid, vol, isreal )
%
%% load data
qweights = [];
qpoints = [];
load('error_quadrature_3d.mat')
%% mean absolute percent error
Vc_err = tl_rlc( qpoints(:,3)', 50, 1.99e8, 2, qpoints(:,1)', qpoints(:,2)', 486.28e6, isreal).';
error = (100/vol)*(qweights.')*abs(1 - tsgEvaluate(lGrid, qpoints)... |
% function to warp images with different dimensions
function XXYY = saveImg_vxvy(im,vx,vy)
[height2,width2,nchannels]=size(im);
[height1,width1]=size(vx);
[XX,YY]=meshgrid(1:width1,1:height1);
XX=XX+vx;
YY=YY+vy;
XX=min(max(XX,1),width2);
YY=min(max(YY,1),he... |
clc
clear
close all
library_path = '../dataset/library/';
load(strcat(library_path,'library.mat'), 'library');
lib_contexts = [];
for i = 1:length(library)
cost_map = library{i}.cost_map;
[ cost_map_x, cost_map_y] = get_cost_map_derivatives( cost_map );
[ f ] = get_simple_features( library{i}.traj, cos... |
function varargout = gui(varargin)
% GUI MATLAB code for gui.fig
% GUI, by itself, creates a new GUI or raises the existing
% singleton*.
%
% H = GUI returns the handle to a new GUI or the handle to
% the existing singleton*.
%
% GUI('CALLBACK',hObject,eventData,handles,...) calls the local
% ... |
function angle = vectorangle(a,b)
angle = acos(dot(a,b,1)./(norm(a)*norm(b)));
end |
function[CPM,CPMpath,G,Pcost,Pdur,Pover,allpths,solution,tpath]=Selection_EvolutionaryOperators(solution,G1,Nant,employee,empnum,task,tasknum)
for k=1:1:Nant
solution(k).taskdur = zeros(1,tasknum);
for j=1:1:tasknum%30
sumtas=0;
for i=1:1:empnum%15
sumtas=sumtas+solution(1).ant(i,j);
end
solution(k... |
function TorF = prime(a)
TorF =1;
for kk=2:a-1
if (mod(a,kk)==0)
TorF = 0;
break;
end
end
if (TorF == 1)
disp('input parameter is prime')
else
disp('input parameter is NOT prime')
end |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Fig 3C: SVD dimensionality reduction
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LOAD DATA
clc
clear
% Paths
paths.main = fullfile('~','Documents','Luyckx_etal_2018'); % change path to folder of scripts
savefolder = 'Crossvalidation_RDM'; % folder to save n... |
function [ u, v ] = getPotFlowPt_alt(r_c,U,x,y)
%% set constants
% set problem geometry in bipolar coordinates
xi2_val = 2.82017;
xi1_val = -6.26456;
a = sqrt(r_c^2*sinh(xi2_val)^2);
%% initialize bipolar variables
xi_val = acoth((a^2 + x.^2 + y.^2)./(2*a*x));
eta_val = acot((-a^2 + x.^2 + y.^2)./(2*a*y... |
function vy = vel_y_final(v0,U,h,N,n_var,K)
% vel_y_final takes as inputs v0 - intial velocity, U - acceleration, h -
% sampling time, N - number of vehicles, n_var - number of design
% variables, and K - number of states, and computes the final velocity in the
% y-direction for every Nth vehicle and Kth state. This ou... |
function [Result,Value,Time]=epiACO(FileName,AntNumber,IterationNumber,evaporation)
%% EpiACO main program for the detection of SNP-SNP interactions
% Input
% FileName: The input file name. for example,
% FileName='dat100' or FileName='Model1_Set1'; Be
% sure that the file... |
scorer_type = 'multilinear';
if strcmp(scorer_type,'linear')
init_conseqopt_linear;
train_conseqopt = @train_conseqopt_linear;
validation_conseqopt = @validation_conseqopt_linear;
else
init_conseqopt_multilinear;
train_conseqopt = @train_conseqopt_multilinear;
validation_conseqopt = @validation_... |
function guiDraw3dModel(pts, n)
colormap('Gray');
scatter3(pts(:,1), pts(:,2), pts(:,3), 3, n*[1;1;1], 'filled' );
|
function interp_coord = downsampleInterp(data, downsample_factor)
assert(downsample_factor > 1, "downsample factor needs to be greater than 1")
ti = linspace(0,1,length(data));
tf = linspace(0,1, length(data) / downsample_factor);
interp_coord = interp1(ti,data,tf,'pchip');
end |
function Knehari = find_Knehari(T)
%%Generate PI
A_PI = T.F;
B_PI = (T.F)';
C_PI = (T.G)*(T.G)';
LyaK.PI = dlyap(A_PI,B_PI,C_PI);
gmin = 0;
gmax = 30;
run = 1;
Fail = nehari_check_g(gmax,T,LyaK);
if Fail ==1
disp('g_max is too small');
return
end
while run
if gmax-gmin>0.0001
... |
%KMGWO source code demo 1.0
% Developed in MATLAB R2017a
% Author and Programmer Hardi M. Mohammed, Zrar kh. Abdul
%e-Mail: hardi.mohammed@charmouniversity.org
% Homepage: https://sites.google.com/a/charmouniversity.org/hardi-mohammed/
% http://www.nci-rc.com/about.php
% ... |
for expnum = 1:1
data = load(strcat('experimentalh0exp', num2str(expnum), '.csv'));
frameNums = [4605; 5647; 5651; 5409; 5409; 5221; 5332; 5418; 5883];
maxfilt = 0.2;
filtrationgap = .00005;
filtrationtimes = 0:filtrationgap:maxfilt;
timesamples = 1000;
endframe = frameNums(expnum)... |
%% preparation. getting fronto parallel.
addpath toolbox_graph
element = 'monitortelevision1';
load(sprintf('../3dModels/ypr/%s.mat',element));
v = load(fullfile('../3dModels/objs',[element '.obj.v']));
f = load(fullfile('../3dModels/objs',[element '.obj.f']));
R = angle2dcm(y,p,r);
v = v*R;
depths = v(:,3);
depthcol... |
%Name: David George
%Student Number: 251004930
T = readtable("speed-ligth.csv");
%%
%Since the population standard devation is not known, and the sameple size
% is less than 30, a t test will be conducted.
%To conduct a t-test, the normality assumption must hold up, same with
%indepependece.
%Checking for normalit... |
function val = Q0011mupq(F00, F11, p, q, Center)
%------------------------------------------------------------------------------
%
% This function computes the central moments mu_{pq} of the gridfunction F
% (seen as a density distribution) where F is a quincunx gridfunction defined
% by the union (F00 U F11).
%
% Inpu... |
% Default parameter values as used in the text.
p.P0 = .05;
p.Vg = 250;
p.Vb = 250;
p.Rg = 2;
p.Rb = 1;
p.gamma = .1;
p.X = 850;
p.a = .5;
p.b = 5;
p.N2 = 1000;
p.tmax = 5;
|
%close all;
figure(1);
set(gca,'FontSize',16);
hold on;
grid on;
%if (f-2*round(0.5*f))==0
plot([-scale_r(NR:-1:1) scale_r(2:NR)]/rmix,[psi_star_2D(NR:-1:1,Nomega) ; psi_star_2D(2:NR,1)],'Linewidth',1);
%end
xlabel('r/r_{mix}')
ylabel('\Psi _* (T.m^{-2})')
axis([-1 1 -0.0005 0.005])
der_psi_star2=zeros(1,NR);
for(r... |
%%
r = [0.3+0.2*1i 0.3-0.2*1i].';
A = poly(r);
r = roots(A);
%%
A3 = conv(A1,A2);
%%
m = 30;
A = [1; -1.79; 0.84]';
C = [1; -0.81; -0.11]';
r = kovarians(C,A,m);
figure(1)
plot(0:m,r)
figure(2)
plot(0:m,r/r(1))
figure(3)
stem(0:m,r/r(1))
%%
n = 2^8;
A = [1; -1.79; 0.84];
C = [1; -0.81; -0.11];
[H,w] = freqz(C,A,n);
R2... |
% 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 [F dFds dFdsig2 dFdB dFdl dFdh] = make_F2(bo, sigma2, lambda, h, dt, varargin)
% version 2 takes lambda, h, and dt as inputs directly, instead of gamma
% and phi; correspondingly, dFdl and dFdh are returned instead of dFdg and
% dFdphi
x = bins(bo);
dB = dxdB(bo);
% Declare F, the forwards markov matrix, an... |
function index = TournamentSelection(K,N,varargin)
%TournamentSelection - Tournament selection
%
% P = TournamentSelection(K,N,fitness1,fitness2,...) returns the indices
% of N solutions by K-tournament selection based on their fitness values.
% In each selection, the candidate having the minimum fitness1 value w... |
classdef paleo_const
% Global constant values
properties(Constant)
% Define model time offset (user preference - all code should obey this)
time_present_yr = 0; % model time at present epoch
%%%% Physical constants
k_CtoK = 273.15; % conve... |
set(0,'DefaultTextFontName','Times',...
'DefaultTextFontSize',10,...
'DefaultAxesFontName','Times',...
'DefaultAxesFontSize',8,...
'DefaultLineLineWidth',1,...
'DefaultLineMarkerSize',7.75);
load('tsp_cnr_sweep_new.mat')
I_total = zeros(length(CNR_sweep),1);
I_total_fdcomm = zeros(length(CNR_sweep),1);
I_total_radar = ... |
function h = cumulative_plot(X, y, predictor, guesses)
% Do prediction.
samples = size(X, 1);
preds = predictor(X);
% For each next guess, compute the number correct chosen by this guess.
cumulative = zeros(1, guesses);
for i = 1:guesses
% Convert the predictions into an output binary v... |
function set_bump0
% bump equilibré voltage et synchro
delai0 =31522324;
voltage0=4000;
r=1.05
tango_write_attribute2('ANS-C01/SY/LOCAL.Ainj.1', 'k1.trigStepDelay',delai0);
tango_write_attribute2('ANS-C01/SY/LOCAL.Ainj.1', 'k2.trigStepDelay',delai0);
tango_write_attribute2('ANS-C01/SY/LOCAL.Ainj.1', 'k3.trigSte... |
% rho_distance.m
%
% Generate plots for the various Rho values based upon the distance from
% the centeroid of the district and the frequency of movements.
addpath('Shared');
clear;
% Note the constants
global PROVINCES;
PROVINCES = {
14, 67.60, 'Kadiogo';
16, 41.13, 'Kourweogo';
21, 73.25, 'Bazega' };
... |
% Tanvir Ferdousi
% Kansas State University
% Last Modified: Sep 2018
% Copyright (c) 2019, Tanvir Ferdousi. All rights reserved.
% Redistribution and use in source and binary forms, with or without
% modification, are permitted
% Creates plots for survival analysis
%% BA_m
figure
plot(BA_m,AR,'LineWidth',2)
xlabel('... |
%Loads an lp from lpnetlib and then
% calls the mehrotra solver and the non symmetric long step
clear all
addpath '../matlab'
addpath '../coneopt'
%Load the file that contains the indices for the
%ufget netlib lps which are in standard form
load 'standard_form_indices.mat'
%Choose a problem from the l... |
% fmrib_pas_EEGActivations() - Remove pulse artifacts from BCG-related selected
% ICs by PROJIC. A choice of methods is available. This program is merely an
% adaptation of the original code fmrib_pas(), as part of the EEGLAB toolbox,
% within the FMRIB plug-in.
%
% Usage:
% >> data = fmrib_pas_E... |
a = 1;
b = 2;
c = 3;
% Binary "scalar" operators
a + b;
a - b;
a * b;
a / b;
a ^ b;
% Binary "vector" operators
a .+ b;
a .- b;
a .* b;
a ./ b;
a .^ b;
% Complex expression
a + b + c;
% Unary expressions
~a;
-a;
+b; |
function [J_x0,J_xf,J_t] = sys_Dg(neq,t,x0,xf)
global sys_params A B C D
% J_x0 and J_xf are row vectors of length n.
% J_t is not used.
F_NUM = neq(5);
J_x0 = zeros(1, length(x0));
J_xf = 0*C;
|
function SuperTitle(titleText)
% SuperTitle(titleText)
% puts one title at the top of a subplot
% John Grogan, 2019
set(gcf,'NextPlot','add');
axes;
h = title(titleText);
set(gca,'Visible','off');
set(h,'Visible','on');
end |
function XiNew = crop_test(img_X)
faceDetector=vision.CascadeObjectDetector('MergeThreshold',2); %Create a detector object
z = 1;
curXi = reshape(img_X',[100 100 3 size(img_X,1)]);
meanXi = mean(curXi,3);
index = zeros(size(meanXi,4),1);
XiNew = zeros(size(meanXi,4),24*24);
for i=1:size(meanXi,4)
meanXi(:,:,:,i) =... |
function y = binomr(n,p)
%BINOMR Binomial random number generator.
% BINOMR(N,P) generates a single random deviate from the binomial
% distribution with denominator n and success probability P.
%
% See RAND.
% GKS 12 Aug 1995, 28 Jul 1999
% Uses naive inversion method.
f = zeros(n+1,1);
for i=0:n, f(i+1) = binomp(i,n... |
classdef (Sealed) SolverCmg < lin.api.Solver & amg.api.HasOptions
%LAMG Combinatorical Multigrid (CMG) linar solver.
% This class adapts the CMG MATLAB code (I. Koutis) to the Solver interface.
%
% See also: SOLVER, SOLVERS.
%=========================== PROPERTIES =====================... |
function varargout = rbPlotTime(data, varargin)
%rbPlotTime plots the time domain spectra
%
%input is swith
%-data: R(1) or R(2)
%-pixel(opt): default is pixel 16. Pixel > 0 gives a trace of 1 pixel.
%pixel = 0 gives a 2d-plot
%
%output is a 2dplot
%
%RB, 20110505: started function
pixel = 16;
while length(varargin)>... |
train_data =importdata('train.data',' ');
train_label = importdata('train.label');
B= zeros(61188,20);
B = B +(1/61188) ;
result = 0;
unique_documents = unique(train_data(:,1));%unique documents in train data
dictionary = containers.Map('KeyType','int32','ValueType','any');%create a dictionary with key as class ... |
% Extends SimpleGA2012
% Generations Returns the number of generations it went through
% Best The best individual found
% Score The best individualís score.
%vecLength, % Size of the vector length
%popSize, % Size of population
%sigma, % guass dist for ... |
function clf = clfLda( p, type, prior )
% Create a Linear Discriminant Analysis (LDA) classifier.
%
% Same algorithm as matlab's function 'classify' (in the statistics
% toolbox). Nice to have in form that actually stores a model that can be
% applied multiple times. For the meaning and usage of prior and type see
% c... |
% setColor : sets line colors
% created 10/19/2016 by Paul Specht
%
%
% This function sets the line colors for the VISAR view method
function setColor(handle,Colors,type,k)
if type < 2
int=4;
elseif type == 3
int=2;
else
int=1;
end
for n=1:length(handle)
set(handle(n),'Color',Colors(n+int*(k-1),:));
e... |
% eSIR_Euler
clear
clc
close all
a = 0.27;
b = 0.027;
f = 18e5;
% Initialize matrices
n = 50000;
S = zeros(n,1); % Susceptible population
I = zeros(n,1); % Active infected population
R = zeros(n,1); % Removals form infected population
tMax = 1000;
t = lins... |
function [anorm,bnorm,cnorm]=normalizace(a,b,c,maska,nejmene)
apom=a(repmat(maska,[1 1 size(a,3)]));
nn=100/numel(apom);
nn(nn<0)=0;
nn(nn>1)=1;
hranice=[double(prctile(apom(:),nn*100)) double(prctile(apom(:),100*(1-(nn))))];
if hranice(2)<nejmene
hranice(2)=nejmene;
end... |
function res = newton_downhill_fun(f, x0, e)
% f:函数
% x0:初始迭代值
% e:精度
x1 = x0 - f(x0) / dif_fun(f, x0);
while abs(x1 - x0) >= e
lambda = 1;
while abs(f(x1)) >= abs(f(x0))
lambda = lambda / 2;
x1 = x0 - lambda * f(x0) / dif_fun(f, x0);
end
lambda = 1;
x0 = x1;
x1 = x0 - lambda * f... |
function XYZ=i_lab2xyz(Lab,IllObs)
%I_LAB2XYZ Convert from Lab to XYZ.
% XYZ=I_LAB2XYZ(LAB,CWF) with size(LAB)=[M 3] returns
% matrix XYZ with same size.
%
% CWF is a color weighting function specification. It can be a
% string, e.g. 'D50/2', or a struct, see MAKECWF. If empty, the
% the default cwf, O... |
function result = UniteOverlappingBB( coloredBB )
%UniteOverlappingBB( coloredBB ) Unit BB with high overlapping under the
%premise that it is noise
threshold = 0.05;
for i = 1 : size(coloredBB, 1)
currentBB = coloredBB(i,:);
for j = i + 1: size(coloredBB, 1)
checkedBB = coloredBB(j, :);
overl... |
function vn = normalize(v)
%NORMALIZE Normalize a vector.
%
% V2 = normalize(V);
% Returns the normalization of vector V, such that ||V|| = 1. V can be
% either a row or a column vector.
%
% When V is a MxN array, normalization is performed for each row of the
% array.
%
% See also
% vectors2d... |
function err_nor = err_H(mesh,ref_SBP,eqn,t,U)
% Description: Outputs the H-norm of the error in the numerical solution.
% The error is normalized with the H-norm of the exact solution.
% Useful parameters
nelem = size(mesh.con,1);
nnode = size(ref_SBP.h,1);
Fperm = ref_SBP.Fperm;
UK = reshape(U,[nnode,nelem]);
err ... |
function [q, M] = conversionMatrix2Quaternion(M, varargin)
% conversionMatrix2Quaternion - function to convert Rotation Matrix to Quaternion coeff
%
% Syntax: q = conversionMatrix2Quaternion(M(3,3))
% q = conversionMatrix2Quaternion(M(1,1),M(1,2),M(1,3),M(2,1),M(2,2),M(2,3),M(3,1),M(3,2),M(3,3))
% q ... |
clear;
clc;
close all;
[x,t] = simpleclass_dataset;
net = newrb(x,t,1e-3,1,500,10);
Y = sim(net,x);
view(net)
y = net(x);
classed = vec2ind(y);
figure(1)
scatter(x(1,:),x(2,:),25,classed,'filled')
figure(2)
plotconfusion(t, y)
|
classdef Logger_console < handle
%LOG Create a logging "daemon" as alternative to "Logger"
% Base.Logger_console(name,visible,fname)
% name = unused
% visible = unused
% fname = unused
%
% Log levels (all are printed)
% 0 -> DEBUG
% 1 -> INFO
% ... |
data = 'free_space';
contact = 'no_contact';
test_folder = 'test';
rnn = 'lstm';
network = '_seal_pred_filtered_torque.csv';
%loss = 0;
loss = [0,0,0,0];
%for file = 0:3
file = 0;
exp = ['exp',num2str(file)];
if strcmp(test_folder, 'test')
joint_path = ['../data/csv/', test_folder, '/', data, '/', contact, '/', ... |
function demoTikhonov(lambda)
if nargin < 1, lambda = 10; end
% Tikhonov regularization for a piecewise smooth function
% Based on code by Uri Ascher
%N = 128;
N = 50;
noise = 0.5;
y = zeros(N,1);
h = 1/N;
for i=1:N
x(i) = (i-1/2)*h;
y(i) = fun(x(i));
end
% synthesize data by adding noise
randn('st... |
%plotting script for sim
t = (JD-JD(1))*(24*60*60);
ang = (pi/180) * (SS.constants.Obliquity_Earth - SS.constants.Obliquity_Moon);
R_eci2mci = [1,0,0;
0,cos(ang),-1*sin(ang);
0,sin(ang), cos(ang)];
%% position
figure, grid on, hold on
plot3(r_eci(:,1), r_eci(:,2), r_eci(:,3))
xlabel('X'),yl... |
%% DIGITAL IMAGE PROCESSING - Aristotle University of Thessaloniki
% Assignment 2 - Summer Semester 2020/2021
% Kavelidis Frantzis Dimitrios - AEM 9351 - kavelids@ece.auth.gr - ECE AUTH
%% Function to extract Sigma values
function s = sigmas(octave,scale,sigma)
% Function to calculate Sigma values for different ... |
function pa_pet_grandmeanscale(file,varargin)
% PA_PET_GRANDMEANSCALE(FILE)
%
% Normalize PET volume image by the gobal mean.
%
% Optional arguments:
% 'display' - values 0 or 1
%
% See also SPM_GLOBAL
% 2012 Marc van Wanrooij
% e-mail: marcvanwanrooij@neural-code.nl
%% Optional input
dspflag = ... |
% for phi_rank=1:17
% imagesc(squeeze(Efield_X_map_phi(phi_rank,:,:)))
% pause(0.1)
% end
for phi_rank=1:33
imagesc(squeeze(Epot_map_phi(phi_rank,:,:)))
pause(0.1)
end |
% Fresnel Diffraction Integrals (See Chapter 4 of Fourier Optics, Goodman)
%% Parameters
% Physical Parameters and Derived Values
lambda = 500e-9; %m
k = 2*pi/lambda;
% Spatial Parameters
w = .002; %m
res = 1000;
x = linspace(-w,w,res(1)); %m
% y = linspace(-w,w,res(2)); %m
% [X Y] = meshgrid(x,y);
% z = (1:400)*10^-... |
% double chain
function e = id_condensed_generate_emission_genotype_nonmissing(freq, is)
num = length(is(1,:));
num_es = 2^(num-1);
num_is = length(is(:,1));
e(1:num_is,1:num_es) = 0;
p1 = freq(1);
p2 = freq(2);
for i = 1:num_is
id = is(i,:);
code(1:num) = 1;
while(1)
shift = 1;
p... |
function plot2AUFC(ax, block)
% numCompletedTrials = block.numCompletedTrials;
[block.trial(arrayfun(@(a)isempty(a.contrast), block.trial)).contrast] = deal(nan);
[block.trial(arrayfun(@(a)isempty(a.response), block.trial)).response] = deal(nan);
[block.trial(arrayfun(@(a)isempty(a.repeatNum), block.trial)).repeatNum... |
function u = create_uncertainty(var,rand)
%CREATE_UNCERTAINTY Creates a struct holding the variability and randomness
% The struct contains the fields `var` which holds the scaling factor and
% `rand` which is meant to be a random number between -1 and 1.
% The fields are meant to be used in this manner. Given a ... |
function [Udd] = EOM(o,p)
N=o;
%%%% Physical Properties%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Msc = 150;%100;% mass of the spacecraft in Kg
%Input mass data for pendulum from CFD and theory
Mp1 =0.1;%2.5;%2.5;%0.1; mass of the pendulum small on the top in Kg
Mp2 =0;% 2.5;%2.5;%4.5;% ma... |
centers_map = containers.Map();
radii_map = containers.Map();
%% Pinky
centers_map('pinky_top') = [0.99; 2.97; -1.29];
radii_map('pinky_top') = 0.14;
centers_map('pinky_middle') = [0.852; 2.583; -1.378];
radii_map('pinky_middle') = 0.16;
centers_map('pinky_bottom') = [0.603; 2.02; -1.489];
radii_map('pinky_bottom') ... |
close all;
I1 = imread('sphere1.ppm');
I2 = imread('sphere2.ppm');
[height, width, dim] = size(I1);
[x, y] = meshgrid(8:15:width, 8:15:height);
figure;
subplot(1, 2, 1);
imshow(I1);
title('First image of sphere');
subplot(1, 2, 2);
imshow(I2);
title('Second image of sphere');
figure;
V = lucasKanade(I1, I2, x(:)', y... |
classdef CommandWindowTestRunDisplay < TestRunMonitor
%CommandWindowTestRunDisplay Print test suite execution results to Command Window.
% CommandWindowTestRunDisplay is a subclass of TestRunMonitor. If a
% CommandWindowTestRunDisplay object is passed to the run method of a
% TestComponent, such as a TestSui... |
function plotData_new(X, y)
%PLOTDATA Plots the data points X and y into a new figure
% PLOTDATA(x,y) plots the data points with + for the positive examples
% and o for the negative examples. X is assumed to be a Mx2 matrix.
figure;hold on;
% Create New Figure
% ====================== YOUR CODE HERE ============... |
function psdPlotMD(fig,psd,rf_offset,gr_offset)
% function psdPlotMD(fig,psd,rf_offset,gr_offset)
% plot RF and gradients on same plot with vertical offsets as indicated
%
% This is part of the Medusa software suite.
% Pascal Stang, Copyright 2006-2012, All rights reserved.
%
% $LICENSE$
% set scaling
if( is... |
function[] = plots(state, type)
%state is an integer value to denote the state
%type is an integer value to denote the type of crime
years = {'2001','2002','2003','2004','2005','2006','2007','2008','2009','2010','2011','2012','2013'};
data = xlsread('~/Documents/Matlab-Crime-Analysis/crimes_count... |
function [r] = distancia(p_x,pXi)
r = sqrt(sum((p_x.center(1:3)-pXi.center(1:3)).^2)); |
function tempregion = decarea(tempgray,dim, cnn)
step = 2;
tempregion = [];
x = size(tempgray,2);
y = size(tempgray,1);
tests = [];
for i = 1 : step : (y - dim + 1)
for j = 1 : step : (x - dim + 1)
temp = tempgray(i:i+dim-1,j:j+dim-1);
tests(:,:,end+1) = temp;
end
end
tests(:,:,1) = [];
tcnn = f... |
function o=getOpenfullP2X7(y)
o=y(:,5)+y(:,6)+y(:,7)+y(:,8)-y(:,7)-y(:,8);
end |
function [Sensitivity,surfaces] = toleranceAnalysis(label,Geometry,nPoints,display)
if nargin < 5
display = true;
end
if nargin < 4
nPoints = 127;
else
nPoints = max(ceil(nPoints/2)-1,1);
end
%%
aperture = Geometry.aperture;
surfaces = Geometry.prescription;
%% raytrace and display
source... |
function quantize(signal, bits)
% Quantizes analog signal to create a digital signal.
%
% Parameters:
% signal - The signal function. A sinusoid signal.
% bits - The number of bits used for encoding.
% The interval signal is going to run.
interval = 0 : 0.1 : 4 * pi;
% Number o... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.