text stringlengths 8 6.12M |
|---|
function prim(pp)
%PRIM (求最小生成树)
%求最小生成树算法,通过prim算法求最优树,并给出相应图像.
%用法:
% 首先输入矩阵:
% map=[起点1 终点1 边长1;起点2 终点2 边长2;............;起点n 终点n 边长n]
% 再用[out,len]=kruskal(map)求最优树
%参数说明
% map----3列邻接矩阵,每行表示一条边.第一列表示起点,第二列表示终点,第三列表示边长
% out---输出边阵:[起点 终点]
% len---输出最优树的总长度
%
%例如
% clear;map=[1 2 30;2 4 5;3 2 6;4... |
function result=func(v, T1, T2, T3, T4)
% 根据温度和速度计算面积,问题3的目标函数
Tt=T(57.4, 43.7,v/60, T1, T2, T3,T4,0.00678);
maxT=max(Tt);
len5=length(Tt);
cnt1=0;
cnt2=0;
sum=0;
for i=2:len5
if(Tt(i-1)<=217 && Tt (i)>217)
cnt1=i;
end
if(Tt(i)==maxT)
cnt2=i;
end
end
for i=2:len5
if ... |
function [ predictedLabel predictiveProbability ] = SOLRpredict(feature,model)
%SOLRPREDICT Summary of this function goes here
% Detailed explanation goes here
%[ predictedLabel predictiveProbability ] = SOLRpredict(feature,model)
%feature: a matrix including input feature values (# of samples x dimensions).
%model: ... |
clc;
clear;
syms x y;
f =(x+y)^2 + (x+1)^2 + (y+3)^2;
syms x1 y1 a; % a是阻尼步长
f1 = (x1+y1)^2 + (x1+1)^2 + (y1+3)^2;
% 梯度:一阶导数
fx = diff(f,x);
fy = diff(f,y);
% 海森矩阵:二阶导数
fxx = diff(fx,x);
fyy = diff(fy,y);
fxy = diff(fx,y);
fyx = diff(fy,x);
grad_f1 = [fx;fy]; % 梯度
grad_H2 = [fxx fxy;fyx fyy]; % 2x2的海森矩阵
% 做图:原始3... |
%Test Cases:
[fruits1] = rottenFruit([1 4 9 7 6 4])
[fruits1_soln] = rottenFruit_soln([1 4 9 7 6 4]);
% fruits1 => 4
% Output variable(s) should be identical to that produced by the solution file
%
[fruits2] = rottenFruit([10 5 6 8 3 1 2 8 5 7 3 15])
[fruits2_soln] = rottenFruit_soln([10 5 6 8 3 1 2 8 5 7 3 1... |
% ANEURALNETWORK : ARTIFICAL NEURAL NETWORK
% Huayu Zhang 2014
% Adopted from Dale Patterson's code $Version: 3.1.2
% How to use
% create an Neural Network: ann = ANeuralNetwork(N); N is a vector
% of the numbers of each layer
% train neural network: ann.train(X, Y, eta, therr, N); [X,Y] are the
% train data, eta is c... |
function [seq] = identifyPhoneSeq(filename)
[x, fs_1]=audioread(filename);
counter = 1;
maxi = 0;
% The for finds the maximum of the signal from the file.
for i = 1:1:length(x)
if(x(i) > maxi)
maxi = x(i);
end
end
siglen = 0.1 * fs_1; % Calculates the lentgh of a ... |
function G54coordinates = getG54Coordinates(point, direction)
if direction(3)<0
direction = -direction;
end
angleXZ = atan(direction(3) / sqrt(direction(1)^2 + direction(2)^2));
angleYZ = atan(direction(2) / direction(1));
if direction(1)==0
angleYZ=0;
end
B = -abs(pi/2 ... |
function [ ] = plotRecognitionRates( )
k = [1 2 3 5 10 15 20 30 50 75 100 150 170];
rate = [];
for i = 1: length(k)
count = faceTest(k(i));
element = count/132;
rate = [rate element];
end
plot(k, rate);
end
|
%%
% *%%
% *%%Начинаем OHLC свечи
% %Функция для ресэмплинга по тикам и объему
function y = TimeOHLC(t, deltas, method)
tlen = height(t); %Длина таблицы
DateTime = [];
da = [];
hi= [];
lo = [];
op = [];
cl = [];
high = [];
low = [];
close = [];
open = [];
vBuy =[];
vSell = [];
nBuy = [];
nSell =[];
dTime =[];
vB = []... |
function draw3()
% do forward kinematics
global posGoal;
global numLink posLink
global h_axes drawLink drawGoal
for i = 1:numLink,
set(drawLink{i},'Parent',h_axes,...
'Xdata', posLink(1, i:i+1), ...
'Ydata', posLink(2, i:i+1), ...
'Zdata', posLink(3, i:i+1), ...
'visible','on');
en... |
function [n,w,xi,N,dNdxi]=C2D6
%====================== ELEMENT INFORMATION =================================
%
% n=number of integration points of the element
% ncoord= numper of coordinates of the element (2D or 3D)
% nodes=number of nodes of the element
n = 3;
ncoord=2;
nodes=6;
%
%==... |
% Read XCAT
clear all
close all
clc
%fid = fopen('MengPhantom1_atn_1.bin'); % change filename
%phant = single( fread(fid,'single') ); % read entire phantom into a vector
%phant = reshape(phant,281,512,601) ; % reshape
% load '1_mm_pelvis.mat';
%load 'DistortedPelvisPhantoms.mat'; % It includes Pelvis1,2,3,4 (300*... |
function [chan h] = channelmodel(pdp,fs,central_frequency,user_speed,fadetype,corrtype,M,psi,theta,phi,time_i,nTX,nRX,TxCorrMatrix,RxCorrMatrix)
%% 产生衰落信道,发射信号滤波, 被SIM_SISO_TEST调用
% % 作者: 赵龙海
% 2012 哈工大通信所
% 输入: data 需要滤波的SC_FDMA信号
% pdp 功率延迟分布
% fs 系统采样频率 : 15k x Nfft
% central_fr... |
classdef DictionarySymSampler < handle
% DictionarySymSampler Class samples
%
% John Bogovic
% HHMI
% August 2014
properties (SetAccess = private )
D; % The dictionary elements:
% rows are variables,
% columns are observations
numDictElem... |
function T=thrust(mp,Isp) %Funcio que calcula l'empenta tant si tenim més d'un ISP com si no.
if (length(mp) ~= length(Isp)), error('Error: Matriu mp no coincideix amb matriu Isp'); end
T = sum(mp.*9.806.*Isp );
end
|
function f = cubic_spline(x, y)
% CUBIC_SPLINE Cubic splines fit to a data set
% For CUBIC_SPLINE(X, Y)
% Inputs:
% X: a vector of values for the independent variable
% Y: a vector of values for the dependent variable
% Outputs:
% f: an inline function that computes the fitted piecewise cubic polynomia... |
function [ acc_k_markov ] = get_acc_k_markov( k_markov )
% Get the size of the K-Markov matrix and pre-allocate the variables
s = size(k_markov);
alphabet = s(1);
N = numel(k_markov) ./ alphabet;
acc_k_markov = zeros(s);
for i=1:N
sum = 0;
for j=1:alphabet
idx =... |
function Data = simBayesConfNORM(modelNum)
%% PARAMETER INPUTS
Data.nTrials = 10000; % number of trials simulated
%properties for circle statistics
mu_cat1 = (-1/16).*(pi);
mu_cat2 = (1/16).*(pi);
kappa_s = 7;%%kappa (concentration parameter, needs to be convereted for derivations to sigma)
Data.KappaS = kappa_s;
s... |
function model = discreteCVmodel(q, r)
% returns a structure that implements a discrete time CV model with
% continuous time accelleration covariance q and positional
% measurement with noise with covariance r, both in two dimensions.
model.f = @(x, Ts) [eye(2), Ts*eye(2); zeros(2,2), eye(2)]*x;
mod... |
function wrapper()
%wrapper: function that runs model fitting on data from all studies, gets
%negative loglikelihoods and AIC socres for the two models
%load data
study_1 = '../data/cleaned/study1_data.csv';
study_2 = '../data/cleaned/study2_data.csv';
% study_3 = '../../data/cleaned/study3_data.csv';
%run comparisons... |
function [data, data_te, vXYZ] = get_upper_layer_data(data,data_te,vXYZ, idx,fname,averaging)
if nargin < 5
averaging = 0;
end
averaged_data = [];
averaged_data_te = [];
averaged_data_vXYZ = [];
for i = 1:max(idx)
if sum(idx==i)>1
averaged_data = [averaged_... |
function [delta,c] = Optimize(obj,i,tex,c,~)
%OPTIMIZE Summary of this function goes here
% Detailed explanation goes here
tex = obj.tm{i}.Img2CroppedTex(obj.tm{i}.Tex2Img(tex));
J = 0;
H = 0;
aux = tex' * obj.tm{i}.pc(:,1:obj.tm{i}.n_c);
for j = 1:obj.tm{i}.n_c
aux2 = obj.J{i}(:,:,j)' * t... |
% Title:
% label_data.m
%
% Desc:
% MATLAB script that reads data loaded and saved in full_batch.mat and
% displays it via MATLAB GUI for the user to label
%
% Three Labels:
% 0 - Neutral
% 1 - Troughs (BUY)
% 2 - Peaks (SELL)
%
% Example
% label_data;
addpath('scripts/');
% const
DAT... |
function xhat_a=graphPrediction(nodes_a,nodes_b,B,x_b)
xhat_a=B(nodes_a,nodes_b)*x_b;
end |
function SaveSelectROI_Outside(TxtFile, NewROI, SelectOrgan)
%---Read file
RowNum=length(SelectOrgan);
IndexBegin=[]; IndexEnd=[];
for i=1:RowNum
%---Data block IndexBegin+1:IndexEnd-1
IndexTemp=strmatch(['// Beginning of ROI: ', SelectOrgan{i}], TxtFile, 'exact');
IndexBegin=[IndexBegin; IndexT... |
close all
clear
clc
addpath tools
%%
filepath = 'C:\Users\TobiasToft\TIMIT\';
subfolders = dir(filepath);
%%
w = hamming(512);
R = round(0.25*length(w));
M = pow2(nextpow2(length(w)));
comp_mat_tot = [];
for i = 3:numel(subfolders)
subFolderName = subfolders(i).name;
subSubFolders = dir([filepath, su... |
function [] = mainKpsPreprocess()
% MAINKPSPREPROCESS Performs all preprocessing required to train the
% keypoint prediction network.
% Declaring global variables
globals;
% Generate annotations over Pascal3D. Store them in annotationDir.
generatePascalImageAnnotations();
% Generate RCNN data files (currently only... |
clc;
clear;
fs = 100; % Sample frequency (Hz)
t = 0:1/fs:10-1/fs; % 10 sec sample
x = (2)*sin(2*pi*0.2*t)+ (1.7)*sin(2*pi*0.6*(t-2)) % 40 Hz component
%+ (2.5)*randn(size(t)); % Gaussian noise;
m = length(x); % Window length
n = pow2(nextpow2(m)); ... |
% % Line comments.
%
% Syntax
% =======
%
% % Anything from the percent sign until the end of line is discarded.
%
% Description
% ============
%
% Example
% ========
% -IRIS Macroeconomic Modeling Toolbox.
% -Copyright (c) 2007-2017 IRIS Solutions Team.
|
function [label_index, full_label_string, condition_vector, es_vector] = ...
define_kimore_classes()
% the .jsons for the Kinetics labels look like this:
% "zzzzE0ncP1Y": {
% "has_skeleton": true,
% "label": "changing oil",
... |
clear all;
% close all;
clc;
addpath(genpath('gpml-matlab-v4.2-2018-06-11'));
% prepare dataset
downSample = 25;
noise = 0; % 0.01 0.02 tested
[ptTrain, normalTrain, limTest] = prepareData(noise, downSample);
% get query points ready
[xg, yg, zg ] = meshgrid( limTest(1,1):0.07:limTest(1,2), ...
limTest(2,1):0.07... |
function out = getout_nma(B0)
% some init
out.algo = '';
out.obj = inf;
out.time = '';
out.iter = 0;
out.rank = size(B0, 2);
out.B = B0;
out.C = '';
out.start_time = '';
|
function plotContour2(label, bintype, pairtype, x_bin, y_bin, D_xy)
hold on;
contour( x_bin, y_bin, D_xy', 'LineWidth', 1 );
colormap('jet');
axis 'square';
xlabel('SNR_t', 'FontSize', 12);
ylabel('\sigma_t', 'FontSize', 12);
xlim([0 500]);
ylim([0 200]);
set( gca, 'XTick', [0 100 200 300 400], 'YTick', [0 50 100 15... |
close all
clear all
clc
load('rx_data_6');
%load('tx_data_4');
Q=4;
delta_f=1;
% plot(X,'.')
nr_data=length(X);
A=abs(fft(X));
% plot(A);
% plot(A(floor(nr_data*0.55):floor(nr_data*0.65)))
Length_train=100;
train_up=upfirdn(train, ones(Q,1), Q, 1);
%Catching frequency of the receiver LO (around -10MHz (approx nu=0.6))... |
function f = ls_kde( x , X , h )
n=size(X,3);
f=0;
for i=1:n
f=f + gkernel( x , X(:,:,i) , h);
end
f=f/n/h;
end
function z = gkernel( x , y , h )
z = 1 / sqrt( 2 * pi ) * exp( -1/2 * norm( ( x - y ) / h )^2 );
end |
bcode=0*d1;
a=ch1_st_pts(1+find(diff(ch1_st_pts)>800)); a=[ch1_st_pts(1) a]; a(end)=[];
b=ch1_inv_pts((find(diff(ch1_inv_pts)>800)));
for i=1:length(a), if abs(a(i)-b(i))>512, bcode(a(i):b(i))=1; end, end
a=ch2_st_pts(1+find(diff(ch2_st_pts)>800)); a=[ch2_st_pts(1) a]; a(end)=[];
b=ch2_inv_pts((find(diff(ch2_inv_pt... |
function [ decisionStumps ] = hw3_train_adaboost( train_data, num_rounds)
%HW3_TRAIN_ADABOOST Summary of this function goes here
% Detailed explanation goes here
[rowSize,columnSize] = size(train_data);
weights = ones(rowSize) * (1/rowSize);
weights = weights(:,1);
display(weights);
decisionStumps... |
function X = DFTsum(x)
N = length(x);
X = zeros(1,N);
for k = 0:N-1
coef = exp(-1j*2*pi*k/N);
for n = 0:N-1
X(1,k+1) = X(1,k+1) + x(n+1)*coef^n;
end
end
end |
function fig = sinead_CorThickness()
% ___________________________________________________________________________
% sinead (Classification of AD Sufferers using Machine Learning)
%
% Copyright 2016 ISRC-Ulster
% Reference
% Youssofzadeh et al, Multi-kernel learning with Dartel enhances
% combined MRI-PET classificati... |
function [ f ] = group_scatter( datain1,datain2,colorall,legendnames )
%plot scatter plots for groups
f=figure;
for i=1:length(datain1)
plot(datain1{i},datain2{i},'.','color',colorall(i,:));hold on;
end
legend(legendnames);FigureFormat(f);
end
|
function [ new_pos, new_vel ] = COMPUTE_NEW_POS( pos, vel )
% Computes new position for the particles and updates its velocity
new_pos = pos + vel;
new_vel = vel;
end |
classdef rx2 < handle
% rx2 Implements CSMA/CA receiver protocol 2
properties
addr % Our address
domain % Collision domain of rx
state % Current state
delay % Current amount of delay
tx % Who is xmitting to rx
next % Next s... |
clc;clear all;
Ac=[0,0,1,0;
0,0,0,1;
0,0,0,0;
0,29.4311,0,0;];
Bc=[0;0;1;3.0001];
C=[1,0,0,0;0,1,0,0];
h=0.01;
[A,B]=c2d(Ac,Bc,h);
QC=[10,0,0,0;0,10,0,0;0,0,10,0;0,0,0,10];
RC=1;
[K,~,~]=dlqr(A,B,QC,RC,0);
K=-K;
sigma_n1=1e-5;
sigma_n2=1e-5;
QN=[sigma_n1,0;
0,sigma_n2];
sigma_v1=2.7... |
function [ProcPwr data] = abuildmodel(bm,varargin)
% buildsp - builds the data spreadsheet for a benchmark
bm = [bm '/' bm];
pmcfile = strcat(bm,'.pmc.csv');
[pmctimes bustran l2miss] = amdpmcestimate(pmcfile);
pmc = [pmctimes bustran l2miss];
impifile = strcat(bm,'.ipmi.txt');
importcsv(impifil... |
function out = trackCCVideoStationaryBeesP(vid,brFilt, brThresh, taglist, nframes)
% Set up dummy variables
%nframes = vid.NumberOfFrames;
%%
totframes = vid.NumberOfFrames; %How many total frames in the video?
sampFrameIndex = floor(linspace(1, totframes, nframes)); %Generate list of frames to sample for stationary... |
%% 绘制点云
points = cell2mat(pointcloud);
% points = F;
% points = Vd;
x=points(:,1);
y=points(:,2);
z=points(:,3);
% plot3(x,y,z,'.','MarkerSize',3);
% rotate3d
figure(1)
pc_tmp(:,1) = x; %调整点云的方位的和xyz轴
pc_tmp(:,2) = y;
pc_tmp(:,3) = z;
pcshow(pc_tmp) |
function [EyeData,cancel]=FindSaccades(EyeData, inSaccParams,inBlinkParams,segmentIndex)
% find saccades and blinks in CRS data based on criteria defined in inSaccParams
% inputs
% inSaccParams - parameters for identifying saccades
% inBlinkParams
% index of segment
% find index of first point where velocity exceeds ... |
function ve = VEMap(x)
%VEMAP Evaluate the engine model given engine speed and pressure ratio.
% VEMAP(X) evaluates the engine model at the given engine speed X(1) and
% the given pressure ratio X(2), and returns the volumetric efficiency.
%
% Syntax
% ve = VEMap(x)
%
% See also VEOptimization
... |
function result = mls_weight( d, h )
% standard MLS weight function
result = exp( -( d.^2 / h^2 ) );
end
|
function paf = graph2paf(nodes, edges, sz, channelsOnly, sigma)
%GRAPH2PAF Converts a set of edges into part affinity fields.
% Usage:
% graph2paf(nodes, edges, sz, sigma)
%
% Args:
% nodes: set of points (N x 2)
% edges: indices into nodes defining directed edges (E x 2)
% sz: grid/image size (1 x 2)
% chan... |
function ph = fplot(b,a)
w=linspace(0,2*pi,512);
numerator=polyval(b,exp(-1j*w));
denominator=polyval(a,exp(-1j*w));
H=numerator./denominator;
subplot(2,1,1)
plot(w./pi,abs(H));
title('Magnitude Response');
xlim([0 1]);
subplot(2,1,2)
plot(w./pi,angle(H));
title('P... |
function AddText(coor,str,size)
txt=text(coor(1)+.475*(coor(2)-coor(1)),coor(3)+.075*(coor(4)-coor(3)),str);
set(txt,'fontsize',size)
|
%MC_DEMO_SOLVE_ADMM Solve matrix completion on graphs with ADMM
%
%
%
% see also: MC_solve_ADMM, MC_demo_grid_search, split_observed,
% sample_sparse, sample_sparse_t, sample_sparse_AtA
%
%code author: Vassilis Kalofolias
%date: Nov 2014
load MC_community_example Gu Gm Xn
Gc = Gu; % columns graph... |
function [rollSUM] = rollSUM(price,period)
%error checking!!
[n,m]=size(price);
if (n>m)
error(['The data input to must be a row vector.']);
end
%calculation
TT=length(price);
winSUM = filter(ones(1,period),1,price);
temp=zeros(1,period-1);
rollSUM=[temp,winSUM(period:TT)];
end
|
function H = solve_homography(pin, pout, option)
% takes a 2xN matrix of input vectors and
% a 2xN matrix of output vectors, and returns the homogeneous
% transformation matrix that maps the inputs to the outputs,
if strcmp(option, 'svd')
H_mat = homography_svd(pin', pout');
elseif str... |
function retval = gini (rows,labels)
counts = class_count(rows,labels);
%disp(counts);
impurity = 1;
for i=1:length(counts)
if(length(rows{1})==0)
prob = 0;
else
prob = counts(i)/length(rows{1});
endif
impurity = impurity - prob^2;
endfor
retval = impurity;
endfunction
|
% function [] = Vanguard()
clear all
close all
% Set Case Title and Plot Option
VLData.Title = 'AEE-12 Vanguard';
VLData.Plot = 'true';
% Set Reference Conditions
VLData.Reference.Area = 375.0; % Reference Wing Area (ft^2)
VLData.Reference.Span = 49.0; % Reference Span (ft)
VLD... |
function obs_frac = get_fraction_obs(obs, frac)
% GET_FRACTION_OBS - Returns a random fraction of the observations
% useful for monte carlo testing
%
% obs_frac = get_fraction_obs(obs, frac);
%
% Input: obs - the full observation struct (slice-type)
% frac - fraction of the observations to kee... |
function varargout = SingCellNetGUI(varargin)
% SINGCELLNETGUI MATLAB code for SingCellNetGUI.fig
% SINGCELLNETGUI, by itself, creates a new SINGCELLNETGUI or raises the existing
% singleton*.
%
% H = SINGCELLNETGUI returns the handle to a new SINGCELLNETGUI or the handle to
% the existing singleton... |
%% Program to denoise given image using local PCA method
% Dated: 15-5-2017
% Author: Seema S Bhat
% Modified by: Sairam Geethanath, version history v00
% v00 - compute_overlap_blocks - took only the point for averaging;
% computed PCA correctly, weighted the 6 directions correctly
%
% please note: each slic... |
% clear; close all;
mydir = fileparts(mfilename('fullpath'));
rootdir = fileparts(mydir);
addpath(genpath(fullfile(rootdir, 'rectify')));
addpath(genpath(fullfile(mydir, 'matlabPyrTools')));
datafolder = '/Users/vickieye/Dropbox (MIT)/shadowImaging/wallImaging/2017-09-13/';
expfolder = fullfile(datafolder, 'experime... |
function videoOut = slitscan(varargin)
% Process video simulating a slit-scan camera.
% SYNTAX
% videoOut = slitscan(videoIn, nLinesPerScan, direction, nLoops,...
% displayVideo, saveVideo)
% INPUTS
% fileName File name of the video to modify
% nLinesPerScan Number... |
function [tp, fp, fn, tn] = svm(train_data, test_data, C, gamma)
X_train = train_data(:,1:(end - 1));
y_train = train_data(:,end);
X_test = test_data(:,1:(end - 1));
y_test = test_data(:,end);
svm_opts = cstrcat('-s 0 -t 2 -m 2048 -q -c ', num2str(C, '%.5f'), ' -g ', num2str(gamma, '%.12f'));
model = sv... |
%% polar single script
%{
Load a single ScanIR data file and plot several frequencies. Use a tukey
window. One can set the tapper amount. We only need 180 degrees for our
polar measurement since we can assume symmetry. There is a bug so we
actually end up getting 181 steps in the ScanIR data. In this script we are
ta... |
function robj = ProcessCell(obj,varargin)
redo = 0;
if(~checkMarkers(obj,redo,'cell'))
robj = variability('auto',varargin{:});
createProcessedMarker(obj,'cell');
else
robj = variability;
end
|
function stoveChangeIdx=find_stove_change(model,data)
|
function y = mswthresh(x,s_OR_h,t,varargin)
%MSWTHRESH Perform multisignal 1-D thresholding.
% Y = MSWTHRESH(X,SORH,T) returns soft (if SORH = 's')
% or hard (if SORH = 'h') T-thresholding of the input
% matrix X.
%
% T can be a single value, a matrix of the same size as X
% or a vector. In this last case,... |
%The function name should correspond to the name of the file. Please remember to make it match the model and iteration numbers
function [bnet, UID] = sampleDag()
% the total number of nodes in the model. This should be the sum of the skill and item nodes
N = 27;
numberOfItems = 8;
numberOfSkills = 3;
UID = 0;
% variabl... |
function labels = trial_data_to_labels( data, key, desired_trial_cols )
for i = 1:numel(desired_trial_cols)
col_ind = strcmpi( key, desired_trial_cols{i} );
assert( any(col_ind), 'Could not find column ''%s''', desired_trial_cols{i} );
indices.(desired_trial_cols{i}) = data(:, col_ind);
end
complete_true = true... |
function [D,d0] = ComputeimageDistance(x,y,u,v,b,e,I1,I2,disp)
%first show 2 images;
%compute the log-fourier transfrom;
[xi1,xi2,fh,ft_r,ft_i]=MyLogImageFourierTransform(x,y,I1,u,v) |
function[translationVector, rotationMatrix]=getMatrix(filename,firstItem,secondItem)
addpath(genpath('/usr/not-backed-up/YAMLMatlab_0.4.3'));
yaml_file = filename;
YamlStruct = ReadYaml(yaml_file);
temp=getfield( YamlStruct,firstItem);
mat=getfield( temp,'data');
col= getfield( temp,'cols');
... |
%HW10 Homework 10
function [num_questions] = hw10()
format compact;
close all;
%Part A
%Q1
kmeans('sunset.tiff', 5, 0, 0, 0);
kmeans('tiger-1.tiff', 5, 0, 0, 0);
kmeans('tiger-2.tiff', 5, 0, 0, 0);
%Q2
kmeans('sunset.tiff', 5, 0, 1, 0);
kmeans('sunset.tiff', 5, 0, 2, 0);
kmeans('sunset.tiff', 5, 0, 6, 0... |
restoredefaultpath;
clear variables;
clc
%%
%%% Path variables
% - csvPath: path to the folder where the csv file is located. A cvs file
% lists all files considered for the training and testing of the model.
%
% - dataPath: path to the folder where the extracted features are located.
% csvPath='/home/gpds/Documents/... |
function errors = Backpropagation(localFields, targets, weights, thresholds)
errors = {};
numberOfLayers = length(thresholds);
outputLocalField = localFields{numberOfLayers};
outputActivation = Sigmoid(outputLocalField);
outputError = SigmoidDerivative(outputLocalField).*(targets - outputActivation);
... |
function [ virtualChassis, chassisMags ] = ...
unifiedVC( robotFrames, axisPerm, lastVC )
%UNIFIEDVC
% [ virtualChassis, chassisMags ] =
% unifiedVC( robotFrames, axisPerm, lastVC )
%
% Uses SVD to find the virtual chassis of the snake for any gait.
% The function finds ... |
%╣´└│function result=ML_ch09_func090201(num)
clear;clc
a=7.9
text=ML_ch09_func090201(a);
fprintf('%s \n',text) |
close all; clear all;
[ xHata ] = gaussMixMMSEEst( 1, 0.5, 0.1, 1, 9, 0.9 );
[ xHatb ] = gaussMixMMSEEst( 5, 2, 0.49, -5, 2, 0.51 );
[ xHatc ] = gaussMixMMSEEst( 1, 2, 0.4, 2, 1, 0.6 );
mu_theta_a = 0.1*1 + 0.9*1;
Sigma_theta_a = 0.1^2*0.5 + 0.9^2*9;
mu_theta_b = 0.49*5 + 0.51*-5;
Sigma_theta_b = 0.49^2*2 + 0.51^2*... |
function [x,isterm,dir] = eventfun(t,Y,p,I)
%% reformatting input and calculation of light intensity etc.
% separating the state variables from Y
A = Y(1:(p.Xn-1)*(p.Yn-1));
Rd = Y((p.Xn-1)*(p.Yn-1)+1 : 2*(p.Xn-1)*(p.Yn-1));
Rs = Y(2*(p.Xn-1)*(p.Yn-1) +1 : 2*(p.Xn-1)*(p.Yn-1) + (p.Xn-1));
A = reshape(A,[(p.Xn-1) (p.... |
function puller(data_buffer,opt_struct,scanner,puller_data,output)
% function puller(data_buffer,opt_struct,scanner,puller_data)
% pull the data to local machine
if ~exist('output','var')
if ~isfield(data_buffer.headfile,'work_dir_path') ...
&& isfield(data_buffer.headfile,'U_runno') ...
&&... |
function [x1,x2,x3]=func8_7(a1,a2)
fprintf('nargin = %d, ',nargin)
fprintf('nargout = %d\n',nargout)
x1=a1+a2;
x2=a1-a2;
x3=(a1+a2)/2;
|
[data1,data2] = textread('Sprinkle_URBAN.txt','%n%n');
dim = length(data1);
plot(data1,data2,'x'); |
clear;
verbose = false;
tic
% for i=1:20
%% ---------- Constants & circuit settings --------------
% number_of_bits = 1+i;
number_of_bits = 6;
input_BW = 128; %This should be the Nyquist frequency, and input should be oversampled wrt this
signal_peak_amplitude = .001;
signal_bias = 0;
Vref = 2;
k = 1.38064852e-23;
T... |
% Output spike train from spike time data
function X = SpikeTrainsFast(ras, p, len, stv, st_mode)
if any(ras(:,1)>p)
error('!! any(ras(:,1)>p)');
end
if ras(end, 2) >= stv*len || ras(1, 2) < 0
% Assume ras(:,2) is sorted.
error('!! ras(end, 2) >= stv*len || ras(1, 2) < 0');
end
if ~exist('st_mode... |
clc;clear;close all;
load('BilinModel_LV_subjects90pct_phases90pct_svd05it_proc05it\BilinModel_LV_subjects90pct_phases90pct_svd05it_proc05it.mat');
TR = triangulation(model.faces,model.mean);
g = trisurf(TR);axis image;
g.EdgeColor = 'w';
% g.CData = model.pointdata.epiendo;
g.CData = model.celldata.part;
Y = mo... |
function dyn_cor = standard_sliding_pairs(ts1, ts2, le, regions)
dim = size(ts1);
% le = 50;
dyn_cor = zeros(regions, regions, dim(1));
for i = 1:dim(1)-le
count = 1;
for r1 = 1:regions-1
for r2 = r1+1:regions
temp1 = squeeze(ts1(i:i+le-1, count... |
%> @file qualityType.m
%> @brief The structural similarity measure to use in the experiment
%> @details Contains an enumeration of the different structual similarity measures available to the experiment. Provides a method to translate the representation to a string.
%> @author Ben Nordin
%> @date 2011-09-01
% =========... |
% Five steps:
% step 1 : Gaussian Filter
% step 2 : Convolution
% step 3 : Non Maximum Supression
% step 4 : Double Thresholding
% step 5 : Hysteresis Thresholding
%
% load an image
I = imread ('rocks.jpg');
figure, imshow(I);
I_gray = rgb2gray(I);
I_gray_double = double(I_gray);
% Step 1
% create t... |
% File: Free_FIFO_Buffer.m @ M4DAC16
% Author: Urs Hofmann
% Mail: hofmannu@ethz.ch
% Date: 17.02.2021
% Description: Frees the allocated buffer memory on the card
function Free_FIFO_Buffer(Obj)
Obj.VPrintf('[M4DAC16] Freeing FiFo buffer...');
% free data buffer
errCode = spcm_dwSetupFIFOBuffer (Obj.cardI... |
%pezw(1, [1 1.5]);
a=(sqrt(2)/2)*exp(j*pi/4);
b=(sqrt(2)/2)*exp(-j*pi/4);
v=conv(a,b)
pezw(1, 1); |
function main_NLI(nu,n,amp0)
% Solving coupled wave equations for SFG
% Source: W. R. Boyd Nonlinear Optics (3rd ed. 2007)
% Input arguments: nu - [3x1] vector, frequencies for the fields in [PHz]
% amp0 - [3x1] vector, relative initial amplitudes for the fields
% [V/nm]
% ... |
function result = ir_lsq(guess, TI, TR, data)
% result = ir_lsq(guess, TI, TR, data)
%
% defines the relaxation in an IR experiment.
% Note: uses the magnitude images (no phase)
% Mo = guess(1);
% T1 = guess(2);
% result = abs( Mo * (1 - 2*exp(-t / T1) + exp(-TR/T1) ) );
Mo = guess(1);
T1 = guess(2);
... |
addpath('~/HELPFUN');
dir = '/mnt/disk1/NUS_WIDE/';
load('/mnt/disk1/NUSWIDE_concept.mat');
n_train = 60000;
traindata = normalize(traindata);
testdata = normalize(testdata);
[~, anchor] = litekmeans(traindata, 1000, 'Maxiter', 15);
indc = randperm(size(traindata, 1), n_train);
sample = traindata(indc, :);
save([d... |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Copyright 2014 Andrew Cohen, Eric Wait, and Mark Winter
%This file is part of LEVER 3-D - the tool for 5-D stem cell segmentation,
%tracking, and lineaging. See http://bioimage.coe.drexel.edu 'software' section
%for details. LEVER 3-D is ... |
addpath('helpers/');
outputFolder = '../results/raw/';
resetFolder(outputFolder);
% iterate all values for L/D(l), entry entry angle(a) and entry speed(v),
% run simulation and dump results in raw format
for lift = 0.0:0.05:0.3
liftFolder = strcat(outputFolder, sprintf('%0.2f/', lift));
mkdir(liftFolder);
... |
N = 100; %Number of random numbers we wish to examine
rand_val_tracker = zeros(1,N); %zero matrix to keep track of the random numbers generated
X_tracker = zeros(1,N); %Matrix to keep track of the records created as we traverse through the random numbers generated
X_tracker(1,1) = 1; %Distance of the first recor... |
data_dir='/scratch/valeryv/data/corpsus/SRS_AFF/'
H = dir([ data_dir 'dice_haus_*']);
HA = dir([ data_dir 'AFF_dice_haus_*']);
dice = zeros( numel(H), 2 );
hausd = zeros( numel(H), 2 );
for i = 1 : numel(H)
id = fopen([data_dir, H(i).name]);
idA = fopen([data_dir, HA(i).name]);
C = textscan(id, '%s %f', ... |
function [speeds, counts, centers] = plotPhaseTrends(gains,statData)
n_bins = 100;
n_speeds = size(gains,1);
speeds = zeros(1,n_speeds);
counts = zeros(n_bins,n_speeds+1);
centers = zeros(n_bins,n_speeds+1);
for s = 1:n_speeds
speeds(s) = gains(s,1);
legend_str{s} = num2str(speeds(s));
[count,cente... |
%Reading the video file using GUI prompt
[FileName,PathName] = uigetfile('*.mp4','Select the .mp4 video file');
v = VideoReader(FileName);
numFrames = v.NumberOfFrames;
%Extracting frames and converting to grayscale
for i = 1:120
frames = read(v,i);
frameArrayg{i}=im2double(rgb2gray(frames));
frameArrayc{i... |
function [suger,Sub_inx,Cin_o,Gardened] = suggestedsubregion(subRs,percent_inclu,Ci,Atlas_parcial_n,La,tissues,data)
suger = zeros(length(subRs),3);
Dis = zeros(length(subRs),3);
Sub_inx = zeros(length(subRs),1);
[row,col] = size(La);
old = Ci;
err3 = 0.0000... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.