text stringlengths 8 6.12M |
|---|
%The program reads the given data.txt file or any provided, uses bubblesort to sort the
%values within the file and created a movie of the bubblesort data plot.
%The created movie plot potraits the bubble sort movement.
%Arguments: A file with numerical data (dimension: 1 * n) is required for this program.
clear; clc;... |
function [h, p, n]=motion_histograms(V,scale)
%[h, p, n]=motion_histograms(V,scale)
% Extracts motion histograms from a video
% by reducing the image size by scale factor "scale"
% after computing image differences
%
% Inputs:
% V -- A video of nf frames.
% scale -- Dimension reduction f... |
function [] = setup_newport_835()
%GET_NEWPORT1830C Gets the reading from optical power meter over GPIB
%% Instrument Connection
% Find a GPIB object.
obj1 = instrfind('Type', 'gpib', 'BoardIndex', 0, 'PrimaryAddress', 21, 'Tag', '');
% Create the GPIB object if it does not exist
% otherwise use the object that was ... |
function net = cnn_init(varargin)
opts.batchNormalization = true;
opts.networkType = 'simplenn';
opts = vl_argparse(opts,varargin);
rng('default');
rng(0);
net_old = importdata('net.mat');
f = 1/100;
net.layers = {};
net.layers{end + 1} = struct('type', 'conv', ...
'filters', {f*randn(7... |
close all
% clear all
clc
Fs = 1000;
t = 0:1/Fs:10;
spike1 = zeros(1,length(t));
spike1(1*Fs) = 1;
spike2 = zeros(1,length(t));
spike2(1*Fs+0.1*Fs) = 1;
spike3 = spike1 + spike2;
spike3 = output.SpikeTrain(1,:);
% spike3 = spikeTrainGenerator(t,Fs,4);
T = 0.03;
t_twitch = 0:1/Fs:1;
twitch= t_twitch./T.*exp(1-t_twitc... |
%% Analyze boarding data
clc
clear all
data = dlmread('boardingDataVaryingBlocks.txt');
planeDim = data(1:5:end,:);
showEvery = 4;
nSeats = unique(planeDim(1:end,2));
nRows = planeDim(1:end/length(nSeats),1);
nBlocks = unique(data(:,3));
randomBoarding = data(2:5:end,:)/60;
backToFrontBoarding = data(3:5:end,:)/60... |
clear all;
height=100;
width=100;
window_s=1;
window_e=height;
window_h=window_e-window_s+1;
ColMap=colormap(parula(101));
%as=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.8];
t=0:2:300;
tau=240;
phi=0.42;
ColMap=zeros(141,3);
ColMap(1:141,2)=linspace(0,1,141);
ColMap(1:141,3)=linspace(0,1,141);
dd='/home/xiaoling/SpiralWave... |
%% input data
user18final = removevars(user18finalfile,{'VarName1'});
gt = user18final(:,{'groundtruth'});
array = table2array(gt);
gt_new = cellstr(array);
gt_class_labels = grp2idx(gt_new);
user18final = removevars(user18final,{'groundtruth'});
user18final = table2array(user18final);
user18final = transpose(user18fin... |
function hyperObj = getHyperObj_gaussRidge(wML)
if nargin < 1
wML = nan;
end
hyperObj.name = 'evidence';
hyperObj.fitFcn = @ml.optMinNegLogEvi_ridge;
hyperObj.opts.gradObj = false;
hyperObj.maxiters = 1e4;
hyperObj.thresh = 1e-6;
hyperObj.fitFcnArgs = {hyperObj.maxiters, hyp... |
function [data,f] = getDataFields(expmt)
reset(expmt);
if isfield(expmt.data,'speed')
speed = expmt.data.speed.raw();
log_speed = log(speed(:));
[~,mus] = arrayfun(@(i) kthresh_distribution(log_speed), 1:20,...
'UniformOutput', false);
mus = exp(nanmedian(cat(2,m... |
clear;
trans = [0.95,0.05;
0.10,0.90];
emis = [1/6 1/6 1/6 1/6 1/6 1/6;
1/10 1/10 1/10 1/10 1/10 1/2];
[seq,states] = hmmgenerate(100,trans,emis);
pStates = hmmdecode(seq,trans,emis);
[seq,states] = hmmgenerate(100,trans,emis,...
'Symbols',{'one','two','three','four','five','six'})
pStates = hmmdecode(... |
% analyze AVMA free RT data
clear all
load ../freeresp
time_bins = .2:.02:.6;
figure(1); clf; hold on
subplot(3,1,1); hold on
hist([dat.trial.time_press],time_bins);
xlabel('RT')
subplot(3,1,2); hold on
hist([dat.trial(find([dat.trial.correct])).time_press],time_bins)
xlabel('RT')
subplot(3,1,3); hold on
hist([dat.t... |
% ----------------------- BEGIN CODE -----------------------
% Close all figures, clear variables in memory and MATLAB command screen
close all ; clear all ; clc ;
% Set the output format to the short format with compact line spacing
format short g; format compact ;
% ax^2 + bx + c
% dx^2 + ex + f
% ex^2 + hx + i
%... |
%LetterStatisticsDemo
clear all
close all
wordsPerLine = 15;
allowedChar = 'abcdefghijklmnopqrstuvwxyz ''';
%%
%N = 1
counts = letterStatistics('gatsby.txt',allowedChar,1);
res = PermsRep(allowedChar,1);
%Bar Graph
label = cellstr(res);
bar(counts);
set(gca,'XTick',1:length(res));
s... |
function [ g,d,norm] = compute_gradient( depth,real_depth,pdc,opt )
[rows,cols] = size(depth);
g = zeros(rows,cols,2);
d = zeros(rows,cols);
for r=1:rows
for c=1:cols
g(r,c,:) = LocalDepthGradient(depth,r,c,opt);
d(r,c) = compute_density(real_depth(r,c), g(r,c,:),opt);
... |
function [assocs, overlap_start_end] = overlapping_segments(seg_list1, seg_list2, same_lists)
%OVERLAPPING_SEGMENTS Computes intersections of segments, returns non-empty pairs
% [ASSOCS, OVERLAP_START_END] = OVERLAPPING_SEGMENTS(SEGS1, SEGS2)
% find all pairs of segments that overlap. ASSOCS contain the
% ... |
function rrse = calRRSE(Xhat, X)
err = Xhat(:) - X(:);
rmse = sqrt(mean(err.^2));
rrse = sqrt(sum(err.^2)/sum(X(:).^2)); |
function [alpha,beta,vel]=kot(vel,x,y,z)
% Function to transfer cartesian co-ordinates (velocity components into
% flow direction), i.e., maximize x-component and minimize (0) y and z-components
% Input: vel - variable with columns of c-ordinates
% x, y, z - number of columns with co-ordinates
% Output: v... |
% Temporal Order EEG: Pre-Processing to-eeg data
% Written by: Josh Phillips 1/2/2013
% Last Revision by: Evan Layher 1/11/2013
% MODIFY TRIGGERS
% This script uses Ben's strsearch function located in the path below
addpath('/nfs/to-eeg/code/functions/')
% This portion of the script modifies the triggers - specifi... |
function NET = gridConnectionVolShifted(nx,ny,pos)
N = size(pos,1);
NodesD = zeros(3*N,2);
NetD = zeros(4*N,2);
shift = 6;
h = 2.^pos(:,3)+shift;
xh = min(nx,pos(:,1)+h);
yh = min(ny,pos(:,2)+h);
k = 1;
for i=1:N
x = pos(i,1);
if x~=1, x=x+shift; end
y = pos(i,2);
if y~=1, y=y+shift; end
... |
function robot = gfxExample(arg)
% gfxExample example of how to produce showmotion drawing instructions
% gfxExample creates a simple planar 2R robot, kinematically identical to
% that produced by planar(2), but adorned with a variety of extra graphics.
% Read the source code to see how it's done. To view this... |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% EE 569 Homework #1
% Date: Sept. 20, 2015
% Name: Faiyadh Shahid
% ID: 4054-4699-70
% e-mail: fshahid@usc.edu
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function channel_out = quantizedChannel8(channel,x_val,avg_1,avg_2,avg_3,avg_4,avg_5,... |
function hfid = clfids2hfid(cid, lfid) %#codegen
% Encode <cid,lfid> pair into a hfid.
% HFID = CLFIDS2HFID(CID, LFID)
% See also HFID2CID, HFID2LFID
hfid = cid*8+int32(lfid)-1;
|
% This file is used to split the dropsonde log files into parts, the
% Columbus V900 records all GPS tracks in a single file unless it is
% stopped and restarted in a very specific way, thus this script allows the
% algorithmic separation of individual GPS tracks from a single long file,
% this file is copied in th... |
% This is the if/else flag version of response collection
% This runs slower (over 10 trials 100ms slower) than the current version
% where the first iteration is separate
t = [];
b = [];
tBeep = [];
for trial = 1:5
x = 0.017; % Initial stimulus time
y = 0.32; % Initial mask time
tPress = []; % flag to te... |
angles = sym('q',[6,1],'real');
robot.bodyHeight = sym('L1','real');
robot.armAngle = sym('qConst','real');
robot.shoulderLength = sym('L2','real');
robot.elbowHeight = sym('L3','real');
robot.wristLength = sym('L4','real');
[T0, ~, ~] = FKfull(angles,"L",robot);
T0 |
%% LIC 9
%There exists at least one set of three data points separated by exactly C PTS and D PTS
%consecutive intervening points, respectively, that form an angle such
%that the angle is not in the range [pi-EPSILON,pi+EPSILON]
%The second point = vertex of the angle
%The first/third point does not coincide with... |
function links = LinkPositions(xB,yB,theta,s1,phi1,s2,phi2,g,k1,k2,L_sp0,L_mB,mB,IB,m1,m2)
%LINKPOSITIONS
% LINKS = LINKPOSITIONS(XB,YB,THETA,S1,PHI1,S2,PHI2,G,K1,K2,L_SP0,L_MB,MB,IB,M1,M2)
% This function was generated by the Symbolic Math Toolbox version 7.1.
% 14-Jan-2017 01:12:21
t2 = cos(theta);
t3 = si... |
function state = FlylabGetObjectState(varargin)
% Return the (x,y,a,vx,vy,va) state vectors of the specified frame from the given data.
%
if nargin==2
filedata = varargin{1};
iFrame = varargin{2};
iStart = 1;
[iStop,n] = size(filedata.states);
elseif nargin==... |
function u = SE0P_Laplace_direct_full(eval_idx, x, f)
% SE0P_Laplace_direct_full Direct evaluation for free-space Laplace
% u = SE0P_Laplace_direct_full(eval_idx, x, f)
%
% Returns the full free-space Laplace potential.
%
% Parameters:
% :param eval_idx: index of source locations where potential should be eval... |
function y = computeAccuracy( labels, gt)
%error y is the average of the error in each of the cluster
%error in each of the cluster is accurate over the whole
C = max( labels) ;%number of clusters
Acc = zeros( C, 1);
for c=1 : C
idx = labels ==c;
gtC = gt( idx);
table = tabulate( gtC);
Acc(c) ... |
clc;clear all;
K=4;
N=7;
msg=randint(1,K)%%生成随机信息位
[H,G] = hammgen(N-K)%%生成汉明码的生成矩阵和校验矩阵
code=encode(msg,N,K,'linear/binary',G)%%汉明码编码
noise=[0 1 0 1 0 0 0];
code_noise=bitxor(code,noise)
rcv=decode(code_noise,N,K,'linear/binary',G) |
clc,clear all,close all,warning off;
%% 2 Dof Robotic Arm Path Planning (Joint Space) and İnverse Kinematics solve
% Written By Raşit EVDÜZEN
% 11-Jun-2016
% Robot % Path Parameter
l1 = 4; % Robot link 1
l2 = 2; % Robot link 2
ll = l1+l2; % total link length
t1 = []; %
t2 = []; %
time = 2; % eac... |
function [snips, times] = LoadIndexSnip(file, channel, indices)
% FUNCTION [snips, times] = LoadIndexSnip(file, channel, indices)
%
% Load snippets from the given file by their index.
%
% This function loads snippets from old-school .ssnp and .rsnp
% snippet files. It is a pure-Matlab implementation of the C++
% functi... |
function [nbn] = makeNBNfft_binaural_V2(flow,fhigh,dur,fs,rho,ITD)
%flow,fhigh, and fs in Hz
%dur in secs
%implement later maybe: adjust samples via pow2 to increase computational speed ...
if flow <0 || fhigh > fs/2
error('flow || fhigh is not cool')
end
if abs(rho) ~=1
error('Currently rho can onl... |
FNP3=figure;
NN = [16 24 32 40];
for i=1:4
N = NN(i);
[G,l,f,X,Y]=obstacle_mihai(N);
c = -f;
[xsol, k1, k2, k3] = GPCG(l, G, c, l, Inf(N*N,1), 2, 3, 1e-9);
subplot(2,2,i);
displayObst(N,X,Y,xsol);
title(['N=' num2str(N)]);
end
annotation('textbox', [0 0.9 0.08 0.04], 'String', 'Figure3');
print(FNP3, '-dpdf', 'F... |
close all;
set(0, 'DefaultFigureWindowStyle', 'Docked');
base_dir = 'C:\Users\Surafel Nigussie\Documents\MATLAB';
cd(base_dir);
f_list = dir('*jpg');N = 20;
img = zeros(288, 352, N);
for i = 1:N
img_tmp = imread(F_list(i).name);
img(:,:,1) = img_tmp(:,:,1);
end
bck_img = (mean(img, 3));
subplot(121);
imagesc(bc... |
%function outdata = highpass2(indata, cutoff)
%
% Luis Hernandez-Garcia @UM 2008 and
% Daniel B. Rowe @ MCW 2008
%
% filters data using a gaussian windowed rect function by multiplication in the
% frequency domain
%
% indata = data to be filtered, n TRs by p voxels
% cutoff = cutoff frequency. It is expressed as a fr... |
close all; clear all; clc;
load imgfildata
% kullanıcıya dosya seçtirme işlemi
[dosya,dosyaYolu] = uigetfile({'*.jpg;*.jpeg; *.bmp; *.png; *.tif'},'Bir görüntü seçin');
dosya = [dosyaYolu,dosya];
image = imread(dosya);
image = imresize(image,[600 800]);
% figure();imshow(image);
gri_r... |
function [est,t,name] = mypi(N)
%MYPI compares several computational methods for estimating pi
%
%USAGE
% mypi uses 20 terms or iterations of various computational methods to
% estimate pi to demonstrate their convergence properties and prints the
% results to the screen.
%
% mypi(N) uses N terms or ite... |
% TRANSPARENTIZECURLEGENDS A helper snippet to set the transparency of the
% legend box(es) of the current figure (or subfigures).
%
% Yaguang Zhang, Purdue, 09/13/2017
hLegends = findobj(gcf, 'Type', 'Legend');
for idxLegend = 1:length(hLegends)
set(hLegends(idxLegend).BoxFace, 'ColorType','truecoloralpha', ...
... |
function [rep, x] = get_rep(X,n,RA)
r = X(1);
linha = 1;
for i = 1:n
if (X(i) > r)
r = X(i);
linha = i;
end
end
#printf("Linha: %d\n", linha);
#printf("R: %d\n", r);
rep = RA(1, linha);
X(linha) = 0;
x = X;
endfunction |
function [ changedImage ] = drawFaceFeatures( pointsMatrix,originalImage )
%UNTITLED4 Summary of this function goes here
% Detailed explanation goes here
if(isempty(pointsMatrix))
errordlg('The user face is not recognized well - can not draw the face','File Error');
end
if(isempty(originalImage))
errordlg('... |
function Zr_update = radialAvg3Dset(param,m)
% RADIALAVG Radially averaqe any 3D matrix Z into M bins
% radial distances r over grid of z
N = min(size(param.B));
[X,Y,Z] = meshgrid(-(N-1)/2:(N-1)/2);
r = sqrt(X.^2+Y.^2+Z.^2);
maxbinval = max(r(:));
% equi-spaced points along r... |
% Converter de graus, minutos e segundos (em vector) para radianos
function out = dms2rad(dms)
out = deg2rad(dms(1) + dms(2)/60 + dms(3)/(60.^2));
end |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Learns the discriminative patches in a dataset, uses method from
% 'Unsupervised Discovery of Mid-Level Patches'
%
% feat_file - name of file containing features and names for all patches,
% should contain vars 'feat' and 'fidx'
% ... |
function RMSE = calculateRMSE(actual, predicted)
error = cell2mat(actual) - cell2mat(predicted);
squaredError = error.^2;
meanSquaredError = mean(squaredError);
RMSE = sqrt(meanSquaredError);
end |
function point_position = my_point_detection(Image_data,rth,w,th,detection_method_label)
[m,n,image_len] = size(Image_data); % 图像矩阵规格
point_position = [];
if detection_method_label == 1
for i = 1:image_len
I = Image_data(:,:,i);
[x,y] = detection_1(I,rth,w,th);
point_position{i,1} = x;
... |
function [nav1,nav2] = process(nav1, Date1, nav2, Date2)
% 把不同周期的nav1,nav2对齐
% -------------------------
% 唐一鑫,20150730
start1 = Date1(1);
start2 = Date2(1);
end1 = Date1(end);
end2 = Date2(end);
if start1 <= start2
if end1 < start2
nav1 = nav1 ./ nav1(1);
nav2 = nav2 ./ nav2(1) .* nav1(end);
... |
function [A,meanVec,stdVec]=normmean0std1(A,meanVec,stdVec)
% normalize each column to have mean 0 and std 1
% Usuage:
% [A,meanVec,stdVec]=normmean0std1(A)
% [A,meanVec,stdVec]=normmean0std1(A,meanVec,stdVec)
% A, matrix of size m by n, with samples in rows, and features in columns
% meanVec: row vector of leng... |
clear;
I = imread('finger1.png');
I1 = im2bw(I, 0.5);
figure;
showgray(I);
I2 = medfilt2(I1,[5,5]);
figure;
showgray(I2);
%flip black and white for thining
I_comp = imcomplement(I2);
%apply thinning:
I_thin = bwmorph(I_comp,'thin',Inf);
figure;
showgray(I_thin);
title('thinning');
%showgray(I);
%find minutia:
[b... |
function ca = writeCommentAnnotation(session, comment, varargin)
% WRITECOMMENTANNOTATION Create and upload a comment annotation onto the OMERO server
%
% ca = writeCommentAnnotation(session, comment) creates and uploads a
% comment annotation owned by the session user.
%
% ca = writeCommentAnnotation(session,... |
function M = mesh_read_meshlab_obj(filename)
% Open file
fid = fopen(filename);
if fid == -1
error(['ERROR: could not open file "' filename '"']);
end
vnum = 0;
fnum = 0;
while feof(fid)~=1
line = fgetl(fid);
if isempty(line), continue; end
if numel(line)>2 && strcmp(line(1:2),'v '), vnum=vnum+1; end;... |
function [data, imageStack, metadata, options] = importMicroscopyFile(fileName, path, tiffPath, options)
% if no options are given
if nargin == 2
tiffPath = path; % use same now
options.noOfCores = 2;
init_parallelComputing(options.noOfCores)
... |
clear; clc; close all;
x = [10e-6;10e-6];
x = [2;2];
track = [10e-6,10e-6];
f = fi(x);
f_ = fi_(x);
p = -f_;
k = 1;
alpha = [1; 10];
H = eye(2)+10e-3;
%% Fletcher Reeves method
while norm(fi_(x(:,k))) > 10-9 && k ~=12
% alpha(k+2) = ls(x(:,k),track,alpha(k+1), alpha(k),H);
alpha(k+2) = 1e-3;
% ... |
%% This code results from the combined work of Jorge Arrieta and Antoine Allard
%
% It uses MatPIV to extract the displacement field between two frames.
% MatPiv 1.7 should be added to your path before running this function
% v0: created the 23/06/2021
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%... |
%% ifindpeak_step
%
% Updates the incremental search for a local optima in a time series. This
% function is to be called after each new sample is acquired.
%
% Note that a local optima is detected after a latency equal to the search
% window size.
%
% Input:
% - curscore: current sample of the stream in wh... |
function [Iv] = rendering_layered_matting_inpainting(Cv, I, Z, C, errosion_radius, avg_alpha, hf_alpha)
r = errosion_radius; % errosion radius
%avg_alpha = 0.96;
%avg_alpha2 = 0.98;
t_thr = 1;
D_hat = recursive_gaussian(D1, avg_alpha)./recursive_gaussian(ones([h w], 'single'), avg_alpha);
FgA = D1 > (D_hat);
FgB = D1 ... |
clear all;
close all;
%constantes
fs=48000;
ts=1/fs;
c=340; %velocidad del sonido
cuarto_x = [0 3]; %dimension x del cuarto
cuarto_y = [0 4]; %dimension y del cuarto
%datos de los audios de cada microfono
load('audios.mat');
[numRows,numCols] = size(audios);
N = numRows;
xn=linspace(0,numRows*ts,numRows); %eje para ... |
while true
clear all;
close all;
master;
end
|
function pts=Draw_iid_Points(p,n)
% function pts=Draw_iid_Points(p,n)
%
% Inputs : p: a pdf (array of dimension d)
% n: number of points to draw independently
%
% Outputs : pts: list of points drawn
dimension=length(size(p));
if (dimension==2)
if (size(p,1)==1 || size(p,2)==1)
dime... |
function T = Tfunction_AGLQ(x, Cm, p, ww, type)
% TGreen.m
% 4th-order Green tensor T
%
% Input: x, three semi-axes of the inclusion, 3*1 matrix;
% Cm, stiffness of the matrix, 4th order matrix;
% p, nodes, n*1 matrix;
% w, weights, n*1 matrix. ww = w * w';
% type, 1 ... |
%WAP to determine time domain and freq domain response of the fixed windows(Hamming Hanning Blackman Rectangle) taking N 25 & 1024.
clc
clear all
close all
N=25;
x=0:30;
black = 0.42-0.5*cos(2*pi*x/(N-1))+0.8*cos(4*pi*x/(N-1));
subplot(2,4,1)
stem(x,black);
title('Blackman (Time Domain)');
xlabel('Samp... |
Fitting_list=0.*E_list_cropped;
for i=1:951
x=E_list_cropped(i);
Fitting_list(i)=-0.009877*(x-200000)/x*exp(-0.8849/x);
end
%plot(E_list_cropped,Fitting_list,E_list_cropped, BG_cropped)
Localized_SI=0.*Int_list;
for i=1:1000
Localized_SI=0.6.*Int_list;
end
plot(E_list, SI, E_list, Int_list, E_list, Localize... |
function [rec_train,rec_test,trainpred,testpred] = evalRecognitionRate(traind, trainl, testd, testl, fwdfun)
T0 = cputime;
y = fwdfun(testd);
[~,my] = max(y,[],2);
[~,ml] = max(testl,[],2);
testpred = my;
rec_test = sum(my == ml) / length(ml);
fprintf('test recognition rate: %.2f%%, elapsed time %fs\n',rec_test*100,cp... |
function [] = OptimizeParameter()
%OPTIMIZEPARAMETER Summary of this function goes here
% Detailed explanation goes here
[hour,minute,second] = getDifferenceInTime;
if isTooLong(hour,minute,second)
a = "NON OK"
minute
second
else
a = "OK";
end
end
function [hour,minut... |
%p0 -> lastWaypoint
%p1 -> nextWaypoint
%p -> current position
%gerenciador dos waypoints. a cada iteração verifica se é preciso tack
%(principal função). A saída é o próximo par de waypoints que o seguidor de
%linha deve seguir.
function waypoint_pair=path_planner_mod(V_in)
global gnc_par
global mdl_par
... |
% Faiyadh Shahid
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% EE 569 Homework #3
% Date: Nov. 1, 2015
% Name: Faiyadh Shahid
% ID: 4054-4699-70
% Email: fshahid@usc.edu
%------------------------------------------------------------------------%
function extended_image = extension1(original_image, wind... |
%%
% The following script allows the calculation of the equivalent permeability
% ke of the wall of a volcanic conduit containing multiple fractures. The
% time-dependence of ke is captured by considering depth- and temperature-
% dependent fracture permeability reduction by viscous sintering.
clearvars; clo... |
function fig = ghaliwg1_stat(varargin);
% ghaliwg1_stat(...)
% IWG1 Stat
ffig = ne_group(varargin,'IWG1 Stat','phaliwg1_statcp','phaliwg1_stattd','phaliwg1_stats');
if nargout > 0 fig = ffig; end
|
function B0 = GKsvdStep(B)
% function B0 = GKsvdStep(B)
% B is an nxn upper bidiagonal matrix with no zero entries inside the band
% B0 = U'*B*V is the updated bidiagonal obtained by performing one step
% of the Golub-Kahan update.
% GVL4: 8.6.1
n = length(B);
% The shift comes from the lower 2x2 od B'*B...
C... |
%the script implements discriminat analysis and K-nearest neighbors
%The code attempts to predict the gender of a person from a set of data for
%6 persons that provides the log(weights) for the gender of the person.
clear
clc
X=[5 4.7 4.4 5.12 4.3 5.44]; %log(weight) of the 6 person sam... |
clc
clear
time = cputime;
% 原图像预处理;
I = imread('image2.jpg'); % 读取图像image2.jpg;
J = rgb2gray(I); % 转换为灰度图像;
[m, n] = size(J); % m = 418,n = 728;
K = imnoise(J, 'salt & pepper', 0.02); % 中值滤波;
L = medfilt2(K);
% figure; imshow(K); title('加噪声原始图')
% figure; imshow(L); title('滤波后图')
map = edge(L, 'canny... |
function maskedImg = getBoxMask(box_im, mask_binary, averageImg, viz)
if nargin < 4
viz = 0;
end
assert(size(box_im,1) == size(mask_binary,1))
assert(size(box_im,2) == size(mask_binary,2));
scaled_average_im = box_im;
mask_binary_comp = ~mask_binary;
scaled_average_im... |
% clear;
% close all;
addpath('..\..\..\Code\Tools\liblinear\matlab');
nexp = 1;
d = 10;
nx = 100;
nn = 2;
for exp = 1:nexp
X = randn(nx,d);
X = projectSphere(X);
w = randn(nn,d); % try different distributions
w = projectSphere(w);
bestID = zeros(nn,1);
for i = 1:nn
bestID(i) = find(w(i,:)*X'==max... |
function loopreporter(it_current,name,itrgap,nfiles)
if nargin==1
fprintf('- %d\n',it_current);
end
if nargin==2
fprintf('%s: %d\n',name,it_current);
end
if nargin==3
if isinteger(it_current/itrgap)
fprintf('%s: %d\n',name,it_current);
end
end
if nargin==4
if ismember(it_current,1:itrgap:nfi... |
function [A,b] = assembly2d_rf(A,b,pde,p,t,elt1,fht1,intmethod)
% function [A,b] = assembly2d_rf(A,b,pde,p,t,elt1,fht1,intmethod)
% Adds the assembled matrix and vector representing the
% given PDE (pde) to the A matrix & b vector.
% This uses a given element (elt1) with the triangulation given by (p,t).
% The feature ... |
function [callPrice, putPrice, callVol, putVol] = blsprice_piecewise(stockPrice, strikePrice, rate, expireTime, timeList, sigmaList)
%BLSPRICE_PIECEWISE COMPUTE A EUROPEAN OPTION OF PIECEWISE VOLATILITY
% Return the price and equivalent vol at timeList(1)
%
% Inputs:
% timeList - a vector of time. Result of... |
function y=delay_v1(x,Fs,N,M,b)
y=x;
for j=1:length(x);
for i=1:N
Delay=i*M*Fs;
if((j-Delay)>0)
y(j)=y(j)+b*x(j-Delay);
end
end
end
end |
function unsortPointScan
% This function will move all files from subdirectories in a pointscan
% folder to the parent directory
% Set current path
p = pwd;
% Get files in the directory
files = dir();
% move all files from the point and reference directories into the
% pointscan directory
for i=1:length(files)
... |
%% Model of Scranton & Vasseur 2016 (Theor Ecol.)
%%% Developped by Picoche & Barraquand 2018
%%% Boxplot for our stable cases (60 or 1 species)
clear all; close all; clc;
afontsize=8;
col=jet(60);
dir_output='./output_simulation/white_noise/morta_variable/';
%Filename for +SE+SND
T = readtable("output_simulation/gr... |
function [J, grad] = lrCostFunction(theta, X, y, lambda)
%LRCOSTFUNCTION Compute cost and gradient for logistic regression with
%regularization
% J = LRCOSTFUNCTION(theta, X, y, lambda) computes the cost of using
% theta as the parameter for regularized logistic regression and the
% gradient of the cost w.r.t. t... |
function [D,G,B] = autoGen_dyn_ss_mat(qf1,ql1,ql2,dqf1,dql1,dql2,g,l,d,r,c,m,I,Ifoot)
%AUTOGEN_DYN_SS_MAT
% [D,G,B] = AUTOGEN_DYN_SS_MAT(QF1,QL1,QL2,DQF1,DQL1,DQL2,G,L,D,R,C,M,I,IFOOT)
% This function was generated by the Symbolic Math Toolbox version 6.2.
% 13-Jun-2015 09:41:20
t2 = cos(qf1);
t3 = cos(ql1);... |
function [p, rmse] = gainPlotCustom2(root, pattern, freq, location_str, loc_logic)
% Analyze complex impulse responses from measurements
% Author: Rick Candell, Mohamed Hany
% Organization: National Institute of Standards and Technology
% Email: rick.candell@nist.gov
if nargin < 5
loc_logic = true;
end
if nargin <... |
function [errorCode, errorMsg,cancelNo] = optEntrustCancel(self, entrustNo)
%optEntrustCancel 在CounterHSO32中重新包装函数EntrustsCancel
% [errorCode, errorMsg,cancelNo] = optEntrustCancel(self, entrustNo)
% --------------------------
% 朱江,20160215
connection = self.connection;
token = self.token;
accountCode = self.ac... |
prompt={'Subject ID:',...
'Session ID:',...
'Group:',...
'Gender ("male" or "female")'};
name='Subject Information';
numlines=1;
defaultanswer={'APYC','Intensity Calibration','Control','female'};
answer=inputdlg(prompt,name,numlines,defaultanswer);
subjectID = answer{1};
session = answer{2};
group = ... |
function [DATA_SPHERICAL_2D, AZ, EL] = ...
spherical_projection(DATA_CARTESIAN_3D, BAND_WIDTH, R_MIN)
% Default to minimum radius of resampling
% of one voxel
if nargin < 3
R_MIN = 1;
end
% Resample the 3D Cartesian data onto
% a 3D spherical grid.
[DATA_SPHERICAL_3D, az, el] = ...
cart3_to_sph3(DATA_CA... |
load sunspot.dat
fSample = 1;
t = sunspot(:, 1);
xOriginal = sunspot(:, 2);
nSamples = length(t);
nOverlap = 0;
% removing mean and detrend
xMeanDetrend = detrend(xOriginal - mean(xOriginal));
% applying log then subtract mean
xLogMean = log(xOriginal + eps) - mean(log(xOriginal + eps));
[psdRaw, ~] = pwelch(xOrigina... |
% Initial visualization. Each x represents a station
hold off;
am= X(:,9);
pm= X(:,18);
plot(am,pm,'x');
xlabel('Availability percentage 8-9am');
ylabel('Availability percentage 5-6pm');
%%
% Initialize variables (X is a variable already in the environment)
K= 3;
numIter= 100;
numRandomInits= 100;
optInd= zeros(size(X,... |
function [output_image] = rgb2normedrgb(input_image)
% converts an RGB image into normalized rgb
[R,G,B] = getColorChannels(input_image);
norm_r = R ./ (R + G + B);
norm_g = G ./ (R + G + B);
norm_b = B ./ (R + G + B);
output_image = cat(3,norm_r,norm_g,norm_b);
end
|
function [YX_neg,YX_pos] = randomSelectSample(X,Y,sample_w,sample_h,pic_w,pic_h,beita1,beita2,gama,tempnum_neg,tempnum_pos,frame)
%***********随机选择负样本***********%
domainX1 = X - beita2;
domainY1 = Y - beita2;
domainX3 = X + beita2;
domainY3 = Y + beita2;
if domainX1 < 1, domainX1 = 1;end
if domainY1 < 1, ... |
% Plot of (D,E) distribution given by D, DStrain and DStainCorr
%===============================================================================
clear, clc
% This script plots the Gaussian distribution over zero0-field splitting
% parameter D and E that EasySpin models based on the spin system fields
% Sys.D, Sys.DStr... |
function output = my_imfilter(image, filter)
% This function is intended to behave like the built in function imfilter()
% See 'help imfilter' or 'help conv2'. While terms like "filtering" and
% "convolution" might be used interchangeably, and they are indeed nearly
% the same thing, there is a difference:
% from 'help... |
# Ian Zabel
# Provided Parameters
# Objective Function: Minimize f(x1,x2)=(1-x1)^2+(2-x2)^2
import math as m
import numpy as np
Y = 5. # Gamma [Y>1]
B = 0.8. # Beta [0<B<1]
E = 1*10**-6 # Epsilon, termination parameter
a = 3. # Scale factor a
N = 2. # Number of variables N
K = N-1. ... |
c = 3e8;
f = 77e9;
% TODO : wavelength
lambda = c / f;
% TODO : the doppler shifts in Hz
f_d = [3e3, -4.5e3, 11e3, -3e3];
% TODO : velocity of the targets
v_r = f_d * lambda / 2;
disp(v_r); |
function [G1 G2 G3] = compute_gradient(Gray,F)
Gray = (Gray-mean2(Gray))/std2(Gray);
% figure, imshow(Gray,[]),
Gx = conv2(Gray,F(:,:,1),'same');
Gy = conv2(Gray,F(:,:,1)','same');
G1 = sqrt(Gx.^2+Gy.^2);
Gx = conv2(Gray,F(:,:,2),'same');
Gy = conv2(Gray,F(:,:,2)','same');
... |
close all
clear
W = randn(2,1000);
Rx = [2 -1.2;-1.2 1];
figure
scatter(W(1,:),W(2,:),2);
xlabel('W_1','FontSize',20);
ylabel('W_2','FontSize',20);
[EVec,Lambda]=eig(Rx);
Xbar=((Lambda)^(1/2))*W;
X=EVec*Xbar;
figure
scatter(Xbar(1,:),Xbar(2,:),2);
xlabel('$\bar{X_1}$','Interpreter','Latex','Font... |
function [u varargout]= se0p_fourier_space(x, f, opt, pre_kernel, k_scaling)
if isfield(opt, 'window') && strcmp(opt.window, 'kaiser')
use_kaiser = true;
else
use_kaiser = false;
end
% initialize time array
walltime = struct('pre',0,'grid',0,'fft',0,'scale',0,'int',0);
% Check
assert(isfield(opt, 'xi'), 'xi must... |
function logp_H = partial_independence(X, psi, alpha)
%%% Partial independence model: one margin fixed (rows margin).
%%% Analytical solution
logp_H = compute_logp_H(X, psi, alpha);
end
function logp_ib = compute_logp_independent_block(X, alpha)
%%% Compute the analytical log likelihood of a matrix under the assu... |
function [x] = translation_dual_quaternion(t)
x = zeros(8,1);
x(1,1) = 1;
x(6:8,1) = t/2;
end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.