text stringlengths 8 6.12M |
|---|
clc
clear all
close all
alt = [0:1:100000];
p = zeros(1,numel(alt));
r = zeros(1,numel(alt));
for i= 1:numel(alt)
p(i)= press(alt(i));
r(i) = dens(alt(i));
end
figure
plot(alt,p)
xlabel('Altitude (m)')
ylabel('Pressure (Pa)')
figure
plot(alt,r)
xlabel('Altitude (m)')
ylabel('Density (kg/m^3)')
function rho = dens... |
function X = sgplvmInitialiseLatentPoint(model,Y,index_in,index_out,type,N,verbose)
% SGPLVMINITIALISELATENTPOINT Initialise latent location given observation(s)
% FORMAT
% DESC Initialise latent location for given observation(s)
% ARG model : sgplvm model
% ARG Y : observation, if multiple observation spaces as cell-... |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Autor: Prof. Alexandre Zaghetto %
% E-mail: zaghetto@image.unb.br %
% Disciplina: Sinais e Sistemas %
% Departamento: Ciência da Computação %
% Universiade de Brasília %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all
close all
clc
%%%%%%%... |
function z1_z2=rou(flat)
[lx,ly]=size(flat);
terrain=flat;
% for i=1:ly-2
% for j=1:lx-3
% z1((i-1)*lx+j)=mountain(i,j);
% z2((i-1)*lx+j)=mountain(i+2,i+3);
% end
% end
% plot(z1,z2);
step=5;
for delta_x=1:lx/2
for delta_y=1:ly/2
z1=0;
z2=0;
i1=0;
for i=1:step... |
function [MSPE_adjusted,p_value]=Perform_CW_test(actual,forecast_1,forecast_2)
% Last modified: 09-03-2013
% Performs the Clark and West (2007) test to compare forecasts
% from nested models.
%
% Input
%
% actual = n-vector of actual values
% forecast_1 = n-vector of forecasts for restricted model
% fo... |
for struc = unique([targets step2OARs step3OARs])
%Find relevant voxel indices
if length(targets)>=2 && struc == targets(2)
% subtract PTV1
mask3M = getUniformStr(struc) & ~getUniformStr(targets(1));
% downsample if necessary.
if sampleRates(struc) > 1
mask... |
function [ MFuns ] = extractMFuns( fuzzyModel, args )
pointsNo = length(args);
MFuns = zeros( pointsNo, fuzzyModel.rulesNo );
% ======== ZMIENNE WYŚWIETLAJĄCE POSTĘP SYMULACJI ================= %
simulation_step = 0; %
letters_written = 0; ... |
clear;
load('kron_wgn.mat');
% load('kron_impulse.mat');
% load('twf_metered.mat');
load('metered.mat');
buses = 1:N;
freq_lin = freq_lin(:,1:50000);
metered=randsample(69,60);
non_metered = setdiff(buses,metered);
noise=randn(size(freq_lin(metered,:)));
lambda2=lambda2(2:6);
U2=U2(:,2:6);
V... |
function y = SINC(x)
% File: SINC.M
% CALL: y = Sinc(x)
% This function computes sin(pi*x)/(pi*x).
y = SA(pi * x);
end;
|
function h = get_treatment_handle( t_i, m_i )
% Based on input arguments, get_treatment_handle sets up a treatment schedule
% and returns a handle h for the anonymous inner function treat. treat can
% then be used by the RK integration to poll the treatment schedule by simply passing a time t.
% T is a vector of time ... |
function [ outVal, outGr, outHes ] = GenTridiag1( x0, VGH)
% Generalized Tridiagonal 1 function:
n = length(x0);
outVal = 0;
outGr = zeros(n, 1);
% computes the value of function in point x0
if VGH(1) > 0
for i = 1:n-1
outVal = double(outVal + (x0(i)+x0(i+1)-3)^2 + (x0(... |
function k = derangements(n)
%derangements
% this function takes as input the size of a set and computes as
% output the number of derangements according to the formula above.
%
% USAGE:
% function k = derangements(n)
%
% INPUT
% - n:
%
% OUTPUT
% - k:
%
f = n;
for i = 1:n-1
f = f*i;
end
k = rou... |
function [basariOrani] = fitnessFunction(kromozom)
load etiketli_output.mat
one_indices = find(kromozom(:)==1);
X=vector(1:60,one_indices);
Y=vector(1:60,8);
Mdl = fitcknn(X,Y); % Datas are classed here.
image_folder='C:\Users\isaim\Desktop\Shape-Descriptors-master\images\test';
file_names = dir(fullfile(im... |
function [var,m]=simplify_modules(var1,m1)
% this function simplifies the module codes
m1;
var=var1;
m=[];
index_or=find(m1==-1);
m_num=length(index_or)+1;
if length(m1)==0
var=var1;
m=m1;
elseif m_num==1 & length(m1)~=0
%initialization
m_temp=m1;
len=length(m_temp);
m_te... |
num = [240];
dem = [1 33 240];
sys = tf(num,dem);
step(sys);
grid;
|
function varargout = alphaCorrectCell(input, crtFactor)
% -------------------------------------------------------------------------
%
% alphaCorrectCell:
% Performs a spectral crosstalk correction.
%
% Description:
% The function alphaCorrectCell multiplies the donor intensities by a
% correction factor alpha an... |
% Comparaison des simulations selon les dynamiques
%
clear all;
close all;
% ------------------------------------------------------------------------------
% Display settings
set(0, 'defaultaxesfontsize' , 25 , ...
'DefaultTextVerticalAlignment' , 'bottom', ...
'DefaultTextHorizontalAlignment', 'left' ... |
function [zi,Adk,Bkw,Mk,LL,PP,T] = colgibbs_run(zi,numiter,...
I,D,K,W,di,wi,ci,citest,Id,Iw,Nd,alpha,beta);
% collapsed gibbs run everything
LL = zeros(1,numiter+1);
PP = zeros(1,numiter+1);
T = zeros(1,numiter+1);
time = toc;
[Adk,Bkw,Mk] = colgibbs_counts(zi,I,D,K,W,di,wi,ci,citest,Id,Iw,Nd,alpha,beta);
f... |
% y = random('norm',2,1,[1000 1]);
% mList = linspace(2-0.2,2+0.2,81)';
% sList = linspace(1-0.2,1+0.2,80)';
% LList = zeros(length(mList),length(sList));
%
% for i = 1:length(mList),
% for j = 1:length(sList),
% LList(i,j) = sum(log(pdf('norm',y,mList(i),sList(j))));
% end
% end
%
% close
% figure, h... |
function [cin_one1,cin_one0,cin_two1,cin_two0]=adder_control(add_enable,cout_one1,cout_one0,cout_two1,cout_two0)
if add_enable==1
cin_one1 = cout_one1;
cin_one0 = cout_one0;
cin_two1 = cout_two1;
cin_two0 = cout_two0;
else
cin_one1 = 0;
cin_one0 = 0;
cin_two1 = 0;
cin_two0 = 0;... |
function [BestChrom] = GeneticAlgorithm (M, N, MaxGen, Pc, Pm, Er, obj)
%% Initialization
% Initialize the population
[ population ] = initialization(M, N);
% Calculate the fitness values
for i = 1 : M
population.Chromosomes(i).fitness=obj(population.Chromosomes(i).Gene(:));
end
[max_val, indx]= sort(... |
function R2 = governing2(x1,x2,y1,y2)
tx1=x1-3;
tx2=x2-3;
%
ta1=tx1^2;
ta2=tx2^2;
tb1=5*ta1;
tb2=ta2*0.25;
%
tc=tb1+tb2;
td=-tc;
te=exp(td);
tf=3*te;
%
R2=y2+tf-exp(-y1);
end |
clear all; close all; clc;
x = load('ex4x.dat'); y = load('ex4y.dat');%[m, n] = size(x);
x = [ones(80, 1), x];
figure
plot(x((y == 1), 2), x((y == 1),3), '+');hold on
plot(x((y == 0), 2), x((y == 0), 3), 'o');hold on
xlabel('Exam 1 score')
ylabel('Exam 2 score')
% x1 = x'*x;
%% Calculate Hessian Matrix x'x
x5 = [0,0,0... |
function SmallGlyPep=joinGlyPep(pepMat,glyMat,modMat)
%JOINGLYPEP: Reconstruct the glycopeptide using information provided in
% pepMat, glyMat and modMat.
%
% Syntax: SmallGlyPep=joinGlyPep(pepMat,glyMat,modMat)
%
% Input: Structures pepMat (peptide), glyMat (glycan) and modMat (PTMs)
% pepMat stores peptid... |
function [ListOfNames] = CheckBadGrids()
%UNTITLED5 Summary of this function goes here
% Detailed explanation goes here
A=evalin('base','whos(''-regexp'',''Set'')');
Names={A.name}; ListOfNames={};
for i=1:numel(Names)
GCGL=evalin('base',...
strcat(Names{i},'.Green_Channel_In_Green_Laser.Positions'));
... |
function [f,edges,num]=fitIncremention(f,edges,num,mean,std,typeApproximation,coefStd)
i = -coefStd:coefStd;
for i = i(i~=0)
buf = mean+i*std;
if (i < 0)
index = find(buf > edges);
edges = insertAtLeft(edges, buf, index);
index = find(buf == edges);
num = insertAtLeft(num, f(edge... |
clear
clc
tol = 1e-6;
%% DATA
m = 100;
p_T0 = 1 .* 10.^5; % [Pa]
p_T0_t = p_T0; % [Pa]
p_T0_m = p_T0; % [Pa]
p_T0_h = p_T0; % [Pa]
T_T0 = 300; % [K]
T_T0_t = T_T0; % [K]
T_T0_m = T_T0; % [K]
T_T0_h = T_T0; % [K]
gamma = 1.4; %for air
MM = 28.84; %evaluated considering a mixture of 0.21 O2 and 0.79 N2
R_gas = 8314; % ... |
%I1 = imread('fasilkomgelap.png')
I2 = imread ('fasilkom.png')
%iNeg = 255 - I1
%imshow (iNeg)
%iSubstraction = I2 - I1
%imshow(iSubstraction)
%iMean = mean(I1(:))
%imshow(iMean)
%imshow(imadjust(I1, [0 1], [1 0]))
%imshow(imadjust(I1, [], [], 0.5))
%imshow(imadjust(I1, [], [], 1.5))
%I1 = imread('fasilkomgelap.p... |
%% Diferencial Evolution - Example
% Antonio Horta Ribeiro - 2016
% Belo Horizonte - Brasil
clear all
clc
addpath('../')
% arg min f(x)
% subject to g(x)
f = @(x) peaks(x(1),x(2));
g = @(x) [(-x(1) + x(2) + 2.3); (x(1) + x(2) + 1.8)];
%% Differential Evolution(DE)
populSize = 14; % Population size.
nVars = 2; % Numb... |
%% create new axes
figure;
axes;
axis auto
set(gca,'Color',repmat(0.5,[1 3]));
%% curve
x=linspace(0,10,200);
y=cos(2*pi*x);
h(1)=SMASH.Graphics.AlternatingLine(x,y);
%% closed rectangle
x=[1 9 9 1];
y=[0.1 0.1 0.9 0.9];
x(end+1)=x(1);
y(end+1)=y(1);
h(2)=SMASH.Graphics.AlternatingLine(x,y);
set(h(2),'ForegroundCol... |
%Least square.m
%Week 5
%preamble
clear all; close all; clc;
%load data
load ('noisy.mat')
%plot
plot(x,y,'b+')
axis([0,12,0,10])
|
function [ clonePOP ] = Clone(matrixPOP)
% This function uses the command repmap and replicates the inicial matrix
% matrixPOP into a new one clonePOP in the following way:
% matrixPOP = 1 0 0 clonePOP = 1 0 0 1 0 0
% 0 1 0 0 1 0 0 1 0
% 1 0 0 0 0 1 0... |
% ========================================================================
%
% Monte Carlo analysis to investigate the sampling properties
% of the indirect estimator of geometric Brownian motion.
%
% Gourieroux et. al. (1993) J of Appl. Eco.
% =====================================================================... |
function [x, cvx_optval]=l1_Subgradient(x0, A, b, mu, opts5)
pseudomu = 100; % 10000*mu
iter = 500;
tol = 1e-7;
x = x0;
% continuation trick
while pseudomu >= mu
k = 1;
alpha = 3e-4;
while k < iter
x0 = x;
g = A' * (A * x - b) + pseudomu * sign(x);
if mod(k,50)==0
alp... |
function [k,lambda_l,lambda_d,lambda_t,num_iter]=alg_NPcmf_parest(Y,Sd,St,cv_setting,nr_fold,left_out,use_WKNKN,K,eta,use_W_matrix)
%alg_NPcmf_parest is a helper function of NPCMF that estimates the parameters:
%K, lambda_l, lambda_d & lambda_t.
%--------------------------------------------------------------------... |
%% Header
% Project Name: Domaci 4.
%
% File Name: main.c
%
% Author: Nemanja Jankovic, 2015/3303
%
% Date: /8/2016
clear all; close all; clc;
%% DEFINES
N = 100;
Cmin = 1e-12;
Cmax = 30e-12;
Lmin = 1e-9;
Lmax = 15e-9;
%% Processing
for i = 1:1
C = Cmin + (Cmax - Cmin)*rand(1,8);
... |
clear all
close all
clc
[FileName,PathName,FilterIndex] = uigetfile('.tif');
Data = loadtiff(strcat(PathName,FileName));
Data = mean(Data,3);
f = figure(1)
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
pcolor((Data))
colormap gray
shading flat
axis image
title('Make an L reading order, 3 po... |
%variable already from main
x=[x1h(:,inliers);x2h(:,inliers)];
[f,e1,e2] = fundmatrix(x);
display(x2h(:,inliers)'*f*x1h(:,inliers))
display('a')
det(x2h(:,inliers)'*f*x1h(:,inliers))
Fm = estimateFundamentalMatrix(x1(:,inliers)',x2(:,inliers)')
display(x2h(:,inliers)'*Fm*x1h(:,inliers))
|
function [J, grad] = costFunction(theta, X, y)
%COSTFUNCTION Compute cost and gradient for logistic regression
% J = COSTFUNCTION(theta, X, y) computes the cost of using theta as the
% parameter for logistic regression and the gradient of the cost
% w.r.t. to the parameters.
% Initialize some useful values
m = l... |
% This script is designed to calculate the interaction energy of a lattice
% of dipoles using the dipole approximation.
% Query user for lattice parameters
[ latticeHeight,latticeWidth,basisVector1,basisVector2,...
unitCellHeight,unitCellWidth,dipoleUnitCell] = getCrystalParameters;
% Create position matrix
[ p... |
%% Test how well corrections of OLDirection_Unipolar works
clear all; close all;
simulate = true;
%% Open hardware
onelight = OneLight('simulate',simulate,'plotWhenSimulating',false); drawnow;
if ~simulate
onelight.setAll(true);
radiometer = OLOpenSpectroRadiometerObj('PR-670');
else
radiometer = [];
end
... |
% Solves a QP in the form of
% 1/2 x'Hx + f'x
% s.t.: Lx <= k
% With the Gurobi QP solver using simplex method
% INPUTS:
% H: The matrix for the quadratic term
% f: The matrix for the linear term
% L: The linear constraint matrix
% k: Linear constraint constant
% vbasis, cbasis (OPTIONAL): basis vectors to a... |
function Noyau = Im2Noyau(Image)
%
%function Noyau = Im2Noyau(Image)
%
%Image = une matrice carree N*N ou N impaire
%Noyau = le tenseur de dim 4 mis sous forme de matrice Nē*Nē
%
[N,N]=size(Image);
if(~mod(N,2))
N=N-1;
end
p=(N+1)/2;
corr=xcorr2(Image)/(N*N);
Noyau=zeros(N*N,N*N);
n=1;
for(r1=1:N)... |
function [chain_length] = compute_chain_length(chain, XY)
% this function computes the cumulative length of a chain that is specified
% by a graph node sequence
% reshaping chain into component edges
chain = chain';
chain(numel(chain)-1,2) = chain(numel(chain),1);
chain(end,:) = [];
chain(... |
function [indx] = my_kmeans(U, numclass)
% U_normalized = U ./ repmat(sqrt(sum(U.^2, 2)), 1,numclass);
indx = kmeans(U,numclass, 'MaxIter',100, 'Replicates',100, 'EmptyAction','drop');
indx = indx(:);
end |
function testAE()
%TESTAE Test cases for absolute error
%
% Author: Ben Hamner (ben@benhamner.com)
fprintf('Testing AE ...');
score = ae(3.4, 3.4);
assert(abs(0-score) < 10*eps);
score = ae(3.4, 4.4);
assert(abs(1-score) < 10*eps);
score = ae(9, 11);
assert(abs(2-score) < 10*eps);
fprintf('tests passed\n');
|
function ROI_Zscore_transform(Ctrl_root, Pt_root, working_dir)
% ROI Z-score transformation
%% ------------------------- SCRIPT INFORMATION ---------------------------
%
% This script will take control + participant ROI (QSM) data and perform a
% Z-score transformation on particpant data, normalising against controls... |
function protein_sol = protein_type_convert(protein_atom,AtomName,resName,protein_resseq)
op_radi=[0
3.325
3.73
3.65
3.635
3.66
3.155
2.895
2.85
2.955
2.785
2.84
2.845
2.735
2.82
2.745
3.015
2.76
3.78
];
%list=flipud(list);
C_3=1;
C_2=2;
C_1=3;
C_ar=4;
O_3=5;
O_3p=6;
O_2=7;
O_co2=8;
O_2v=9;
N_2=10;
N_am=11;
N_pl... |
function ts_in = ShuffleTS(cfg_in,ts_in)
% function ts_out = ShuffleTS(cfg,ts_in)
%
% shuffle spikes in ts struct
%
% INPUTS:
%
% ts_in: input ts
%
% OUTPUT:
%
% ts_out: shuffled ts
%
% CONFIGS:
%
% cfg_def.mode = 1; % 1: shuffle labels, 2: shuffle ISIs, 3: uniform random
% with same number of spikes
% cfg_def.t0 = 0... |
function [W,PP] = bone_heat(V,F,C,P,BE,CE)
% BONE_HEAT computes "bone heat" weights from "Automatic Rigging and
% Animation of 3D Characters" by Baran and Popovic.
%
% W = bone_heat(V,F,C,P,BE,CE)
%
% Inputs:
% V list of vertex positions
% F list of face indices, for 3D F is #F by 4, for 2D F is #F ... |
function tiffRetileProd(input,tiles_dir,output)
%TIFFRETILEPROD concatenates small tiles into a single high resolution
%tiled Tiff image.
%Output image are predefined by the width and height of the input.
%Information of the tiles is found in the metadata of the input.
%
%Syntaxis: tiffRetileProd(input,tiles_di... |
AverageBER = 0;
AverageOT = 0;
AverageRPC = 0;
NumberOfSimulations = 1000;
startErrorRate = 0.0000;
for j = 1:50
startErrorRate = startErrorRate + 0.0002;
for i = 1:NumberOfSimulations
x = Simulation();
x.setModelVer('BEC') % BSC, BEC, CEC
x.setErrorControlVer('2z5') % CRC32, 2z5, PB
x.... |
App = GeometryApp;
|
function recommend =recommend()
load('link.mat');
load('malicious.mat');
price=zeros(20);
for i=1:20
for j=1:20
if(link(i,j)==1)
for k=1:5
if(j==malicious(k)||i==malicious(k))
price(i,j)=price(i,j)-randi([1... |
function combine_SNR_mat_files_aston
%Written by Xing 4/2/19
%Combines SNR values across NSPs.
% date='140819_B2_aston';
% date='150819_B2_aston';
date='160819_B2_aston';
allChsSNR=[];
for instance=1:8
copyfile(['X:\aston\',date,'\mean_MUA_instance',num2str(instance),'_new.mat'],['X:\aston\aston_resting_state_data\... |
function parms = compassGaitConfig(parms)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
parms.phase(1).knotNumber = 21;
parms.phaseNum = length(parms.phase);
%% Bounds
parms.maxAngle = pi/3*[1 1];
parms.maxAnglularVel = inf;
parms.maxAnglularAccel = inf;
parms.maxTorque = 100;
%%
ql... |
function [fGG,phi] = getGG(formula,args,k)
global W Wtotal Z zLoop ZLoop bigM epsilon;
if length(args)>1
disp('GG takes a single argument');
asset(length(args)==1);
end
% number of agents
N = length(W);
% number of states
I = size(W{1},1);
% time horizon
h = size(W{1},2)-1;
fGG = [];
z = [];
for k = 1:h
... |
function cqkernel=CONSTQ_getKernel(sr, varargin) %,bpo,fftWin, threshold , msgBox, algorithm)
%This function return a kernel for evalutate the constant Q transform%
%It's possible to use two types of implementation
%For default i use one based on the work of Benjamin Blankertz
%http://wwwmath.uni-muenster.de/logik/... |
classdef ParCommTrainTaskSpec < rl.task.TaskSpec
% ParCommTrainTaskSpec
% Revised: 6-25-2019
% Copyright 2019 The MathWorks, Inc.
properties
TrainOpts
Agent
Env
HostCommunicator
end
methods
function this = ParCommTrainTaskSpec(env,agent,trainOpts,hostComm)
... |
% run ruiqi training and testing in one file multiple times
clear;
%% list for my annotation 1
imList = readFileList('ruiqi_train.m');
opt.modelName = 'model_07_myAnno01.mat';
opt.cacheName = 'cache_04_myAnno01/';
%% list for ruiqi's annotation
imList = readFileList('ruiqi_train.m');
opt.modelName = 'model_08_ruiqiAn... |
function plotshaded(x,y,fstr,levels,outliers)
% x: x coordinates
% y: either just one y vector, or 2xN or 3xN matrix of y-data
% fstr: format ('r' or 'b--' etc)
%
% example
% x=[-10:.1:10];plotshaded(x,[sin(x.*1.1)+1;sin(x*.9)-1],'r');
if nargin < 5
if exist('outliers','var') == 0
outliers = 0;
else
... |
function timings=flipBit(bit,trial)
%pds.datapixx.flipBit flip a bit on the digital out of the Datapixx
%
% pds.datapixx.flipBit flips a bit on the digital out of the Datapixx
% box and back.
%
% THIS FUNCTION IS DEPRECATED: See pds.datapixx.strobe for up-to-date
% event sync signaling with the Plexon omniplex sys... |
function eterna_create_rdat_files( rdat_filename, target_name, structure, sequence, area_bsub, eterna_sequence_files, seqpos, goodbins, data_type, added_salt, bad_lanes, min_SHAPE, max_SHAPE, threshold_SHAPE, EteRNA_score, comments, darea_bsub );
% eterna_create_rdat_files( rdat_tag, target_name, structure, sequence, a... |
conn = database('data','root','66196619','com.mysql.jdbc.Driver','jdbc:mysql://localhost:3306/data')
curs = exec(conn,'select closeprice,highprice,lowprice,openprice from data.his_idx where symbol ="399006" order by date desc limit 10')
curs = fetch(curs)
data0 = curs.Data
num = rows(curs)
data1 = cell2mat(data0)
data2... |
function [low, high]=jacknife(ctrytbl,ynames)
%this function runs the jacknife procedure
seed=20200709;
rng(seed);
M=10;
%avoid adr being 0 in a country for all firms
varlist={'SIZE','BM','fht','ivol','ret','roe','cash','invop','capex','ppe','rdratio','DIV','dy','close','lev','analyst','fxsale','ADR'};
if sum(ctry... |
function run_inputs = Tests_setup(model_name)
%
path_to_code = which(['Testing_', model_name]);
[pathstr, ~, ~] = fileparts(path_to_code);
% input_file_loc is the location of the model input files.
% scratch_loc is the location of the temporary file space. Nothing is kept here.
% data_loc is the location to store the... |
function channel_quotient_img=CQI(img)
%------Channel Quotient Image------%
%------input img must is a color image------%
temp_img=double(img);
channel_quotient_img=double(zeros(size(img)));
channel_quotient_img(:,:,1)=channel_divide(temp_img(:,:,1),temp_img(:,:,2));
channel_quotient_img(:,:,2)=channel_divide(temp_i... |
function s = num2estr(x)
% Get original formatting options
fmt = format;
% Change global formatting to engineerig mode
format short eng
% Get string
s = strtrim(evalc('disp(x)'));
s = trimzeros(s);
% Reset formatting options
format(fmt);
end |
function [err,llh]=Likelihood(inputdata,outputdata,inputtest,outputtest)
[N,d]=size(inputdata);
[Ntest,~]=size(inputtest);
[~,c]=size(outputdata);
Kmax=150;
Iiter=4000;
lamda=0.1;
errortest=zeros(Kmax,1);
likelihood=zeros(Kmax,1);
% for k=1:Kmax
for k=36:36
tic
k
... |
function [ res ] = KNN( X1, Y1, X2, Y2, nk, distance)
mdl = fitcknn(X1,Y1);
mdl.NumNeighbors = nk;
mdl.Distance = distance;
labels = predict(mdl, X2);
res = mismatchError(labels, Y2);
end
|
function [ B ] = removeislands( A, CONNECTIVITY, minislandsize )
%REMOVEISLANDS removes islands from each phase of the image. #parallel
% The image is segmented into NUMPARTS layers where the Nth layer is a
% boolean array of x >= N. Island are removed from each layer and then
% blended downwards.
%
% INPUTS
% ... |
function [varargout] = args_with_default_values (args,varargin)
nargs = length(varargin);
varargout = cell(size(varargin));
for i=1:nargs
varargout{i}=arg_with_default_value(args,i,cell2mat(varargin(i)));
end
end |
%% PLOT OF THERMODYNAMICAL PROPERTIES OF NH3 USING CoolProp
%
% Version 4
%
% Franco N. Ferrucci
% ferruccifranco@gmail.com
% Sept 2018
%% Cleanup
close all
clear
% clc
%% Parameters
% Resample factor:
N = 20;
% Choose which set of plot to print:
plot_saturation = 0; % 1 for YES, 0 for NO... |
function[f] = soli_tunneling_IC_trapping( A, asoli, zmax, hstretch, zjump, z0, wave_type)
debug_on = 0;
% Generate jump conditions
vscale = ((A-1)/2);
upshift = 1+vscale;
if strcmp(wave_type,'d')
wave = @(z) upshift - vscale*tanh(1/hstretch*(z-zjump));
[ zDSW,phiDSW ] = conduit_soli... |
close all;
clearvars;
sca;
PsychDefaultSetup(2);
screens = Screen('Screens');
screenNumber = max(screens);
black = BlackIndex(screenNumber);
white = WhiteIndex(screenNumber);
grey = white / 2;
[window, windowRect] = PsychImaging('OpenWindow', screenNumber, grey);
Screen('BlendFunction', window, 'GL_SRC_ALPHA', 'GL... |
repeatNumber = 1000;
matrixSize = 7;
changePercentage = 80;
changePossibilityThreshold = 0.3;
result = {7, repeatNumber};
for i=1:1:repeatNumber
[A_consistent, wg_consistent] = GenerateConsistentMatrix(matrixSize);
A_begin = AddInconsistency(A_consistent, changePercentage, changePossibilityThreshold);
resul... |
function [TP,FP,FN,TN,F1,Recall,Precision] = GaussianEvaluation(output,groundtruth)
%Evaluation Metrics for the Non-recursive Gaussian modeling for background substraction
%The function compute TP,FP,TN,FN,F1 of a set of images
TP=0;FP=0;FN=0;TN=0;F1=0;Recall=0;Precision = 0;
for i=1:size(output,3)
... |
function photoreceptorClasses = CVDToPhotoreceptorClasses(CVD)
% Return default photoreceptor classes for specified CVD
%
% Syntax:
% photoreceptorClasses = CVDToPhotoreceptorClasses(CVD)
%
% Description:
% Takes in a string specification of a color vision deficiency, and
% returns array of photoreceptor classe... |
clear; clc; close all;
load('data.mat', 'loa_data')
% fprintf('Context alone\n')
% load('data', 'rep_context_data');
% Y = rep_context_data(:,act_cols,:);
% context_sd_matrix = Y;
% save('PLOS_Data\semantic_description_matrix.mat', 'context_sd_matrix')
%
% fprintf('Modifier alone\n')
% load('data', 'modifier_data');... |
function atdisplay(verbosity,message)
%ATDISPLAY checks the verbosity level in the global variable GLOBVAL
% and displays message if this is greater than the verbosity
% for this message.
%
% See also NUMDIFPARAMS
global GLOBVAL
if isfield(GLOBVAL,'verbosity')&& verbosity<= GLOBVAL.verbosity
di... |
%% Electrolyte Diffusion Coefficient Function: D_e(c_e) [m^2/s]
% Created July 12, 2011 by Scott Moura
function [D_e,varargout] = electrolyteDe(c_e,p)
% From DUALFOIL LiPF6 in EC:DMC, Capiglia et al. 1999
%D_e = 5.34e-10*exp(-0.65*c_e/1e3);
%D_e = 5.34e-10*ones(size(exp(-0.65*c_e/1e3)));
D_e = p.D_e*ones(size(exp(-... |
PC_IP = '10.42.0.33';
BEAGLEBONE_IP = 'http://10.42.0.14';
% Initialise ROS on remote master
setenv('ROS_MASTER_URI', strcat(BEAGLEBONE_IP, ':11311'))
setenv('ROS_IP', PC_IP)
rosinit
engine_pub = rospublisher('/car/actuator_engine_update',rostype.std_msgs_Float64)
engine_msg = rosmessage(engine_pub);
steering_pub = ... |
function varargout = nidaqsetup(varargin)
% NIDAQSETUP M-file for nidaqsetup.fig
% NIDAQSETUP, by itself, creates a new NIDAQSETUP or raises the existing
% singleton*.
%
% H = NIDAQSETUP returns the handle to a new NIDAQSETUP or the handle to
% the existing singleton*.
%
% NIDAQSETUP('CALLBACK'... |
function plotFig3c(save_fig,fig_name,ax_view)
% Plots median threshold across clones and rotations at each location on
% layers 1-5, adjacent to each other, as in Fig. 3c
if nargin==0
save_fig = 0;
fig_name = 'Fig3c';
ax_view = [-89.2 45]; % [-89.2 70.8]
end
mat_dir = addPaths;
% Simulation settings
nrn_mo... |
% MJLPPC.M
% For plot of RF pulse
% Called by mjljm
mjlppv = get(mjluipp,'Value') ;
if mjlppv == 1 ;
set(mjluipp, 'BackGroundColor', 'white') ;
else ;
set(mjluipp, 'BackgroundColor', [0.501961 0.501961 0.501961]);
end ; |
clear;
img = double(imread('rec_image.png'));
theta = 900;
p_start = [-100,-100];
[A,x] = radon_full(img,theta,p_start);
res_A = reshape(A,theta,[]);
res_img = reshape(img,[],1);
y_pro = res_A'*x;
image(reshape(y_pro,[],256));
|
% function test188
%TEST188 test concat
% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
% SPDX-License-Identifier: Apache-2.0
fprintf ('test188 ----------- C = concat (Tiles)\n') ;
[~, ~, ~, types, ~, ~] = GB_spec_opsall ;
types = types.all ;
rng ('default') ;
d = 0.2 ;
n1 = 2 ;
n2 =... |
function [ AZI_DT ] = Map_ClockwizeAzi2CounterClockwisefromSAzi( AZI )
% Convert clockwise azimuth from north to Dahlen and Tromp convention,
% measured counterclockwise from due south...
AZI_DT = AZI;
AZI_DT(AZI <= 180) = 180-AZI_DT(AZI <= 180);
AZI_DT(AZI > 180) = 360- (AZI_DT(AZI > 180) - 180);
%AZI = AZI_DT;
... |
clear all
close all
clc;
% Load Label.mat
path2Label = 'C:\Users\jsalveta\Desktop\Data\FAROFA_2\EK80\HAC\Cruise_FAROFA_2\Treatment20200120_010220_FISH\Label\Label.mat';
load(path2Label,'ContourDepth','ContourIndPing','LabelIndex'); clear path2Label;
save(path2Label,'LabelName','-append')
ContourIndDepth = NaN(size(C... |
% clear all;
function [ x t lvl ] = generate_bursty_signal(seed = [])
% ============================== Parameters ===============================
REGULARIZATION__ = 1;
QUANTIZATION__ = 1;
% upsampling
kResolution = 200;
kLambda = 2;
% sinc/dirichlet
kRecKernel = 'sinc';
... |
%chaos02.m
% Runge-Kutta Solutions to Equations of Motion
% Modelling Duffing oscillators: free, viscous damping, and forced motions
% POINCASRE SECTIONS
% Ian Cooper
% email: ian.cooper@sydney.edu.au
% School of Physics, University of Sydney
% 180827 / Matlab version R2018a
% DOING PHYSICS WITH MATLAB
% https... |
clc
clear
close all
format long
%%
%网格信息
mesh.type = 'triangular';
mesh.left = 0;
mesh.right = 1;
mesh.bottom = 0;
mesh.top = 1;
mesh.hx = 0.25;
mesh.hy = 0.25;
%%
%方程信息
pde.exact_sol.u = @(x, y) x .* y .* (1 - x ./ 2) .* (1 - y) .* exp(x + y);
pde.exact_sol.u_x = @(x, y) (y - y.^2 - x .* y + x .* y.^2) .* exp(x + y)+... |
function [b,K] = arap_rhs(varargin)
% ARAP_RHS build right-hand side of global poisson solve for various ARAP
% energies. For examples see Sorkine and Alexa's ARAP (see equation 8 and 9):
% ∑ wij * 0.5 * (Ri + Rj) * (Vi - Vj)
% j∈N(i)
%
% b = arap_rhs(V,F,R)
% [b,K] = arap_rhs(V,F,R,'ParameterName'... |
% This is the kernel function for the Skaggs and Kabala problem
% from Parameter Estimation and Inverse Problems, 3rd edition, 2018
% by R. Aster, B. Borchers, C. Thurber
%
% xx a vector of positions
% tt a vector of times
% params a 2 element array where the first element is the velocity
% an... |
% function calculate the bestfit residuals given the intrinsic
% parameters and others ...
% May 14, 2013
function [bestfitResiduals,varargout]=bestfitResidualsfunc(x,inParams)
%global Np alphaP deltaP kp N timingResiduals sd yr
global kp
xmaxmin = inParams.xmaxmin;
% transform the standard coordinates [0,1] back to... |
format long e;
n = 1/2;
while(n >= 1/512)
fp = (-3*e.^(0) + 4*e.^(0+n) - e.^(0+2*n))/(2*n);
real = 1;
abs1 = abs((real-fp));
abs2 = abs(real-fp)/(n*n);
fprintf("%f\t%e\t%e\t%e\n",n,fp,abs1,abs2);
n = n/4;
end
|
clear all;
close all;
clc;
addpath('./Functions');
Screen('Preference', 'SkipSyncTests', 1);
try
%===== Parameters =====%
initialCash = 10000;
initialStock = 10;
initialStockPrice = 100;
totalTrials = 100;
practiceTrials = 15;
resultTime =8;
d... |
function I_trans = apply_H(I,H)
%Original image
[m, n, color] = size(I);
[X,Y] = meshgrid(1:n,1:m);
%Compute size of destination image
x_min = n;
x_max = 0;
y_min = m;
y_max = 0;
for i = [1,n]
for j = [1,m]
edge_pos = H*[i, j, 1]';
... |
function arplot_EPBI_TC(monthStr, days, year1, month2Str, days2, year2)
%ARPLOT_EPBI_TC - Plots EPBI system thermocouple data from the ALS archiver
% arplot_EPBI_TC(Month1 String, Days1, Year1, Month2 String, Days2, Year2)
%
% EXAMPLES
% 1. arplot_EPBI_TC('January',22:24,2009);
% plots data from 1/22, 1/23, and ... |
function filename = fileoptn(mode)
% FILEOPTN File pulldown menu.
% FILEOPTN handles New, Open, Save, Save As.., Print, and Exit
% options under the File pulldown menu.
% Author: Craig Borghesani
% Date: 9/4/94
% Revised: 10/18/94
% Copyright (c) 1999, Prentice-Hall
% obtain handle informa... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.