text stringlengths 8 6.12M |
|---|
function [g] = delete(g,k_node,k_edge)
%--------------------------------------------------------------------------
%
% Copyright (c) 2009-2011 Jeffrey Byrne
%
%--------------------------------------------------------------------------
k = setdiff(1:nsd.graph.size(g), k_node); % nodes remaining
g.adj = g.adj(k,k);
g.x... |
%{
Steps:
1. Process data - copy values of continuous features; for discrete features (like gender, class) create appropriate number of additional features
2. Normalize data
2. Run logistic regression as the final outcome is boolean (survived or not). Fminunc!
3. Split training data into train + cross validation to im... |
function [ signal ] = createSignal(F,numberOfHarmonics,duration,Fs,step)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
t=0:1/Fs:duration;
signal=0;
if numberOfHarmonics>0
for i=1:step:numberOfHarmonics
signal=signal+cos(2*pi*i*F*t);
end
end
|
function S = simple_stats(N)
aver = mean(N, 2);
med = median(N, 2);
mini = min(N, [], 2);
maxi = max(N, [], 2);
S = [ aver med mini maxi ];
end |
function range = phaserandomcmd(Yr, Y,yI,tsi,diffwshift,varN,vol,yrSt,yrEnd, interval,iter,yrCensor,cmdMethod)
%PHASERANDOMCMD Produce lower and upper bounds of confidence interval for
%CMD using iter instances of phase randomization
% INPUTS:
% Yr: NX1 Year vector
% tsi: NX1 vector of processed TSI corre... |
function f = fcnTSP(varargin)
% fcnTSP(distance)
% Loads a distance (cost) matrix.
%
% f = fcnTSP(permutation)
% Evaluates a permutation using a distance matrix that has been previously
% loaded.
%
% fcnTSP
% Erases the distance matrix.
%
% See also: invTSP, tableTSP, plotTSP
%**************************************... |
function disph5content(fnm)
plist = 'H5P_DEFAULT';
fid = H5F.open(fnm,'H5F_ACC_RDONLY',plist);
gid = H5G.open(fid,'/');
root_info = H5G.get_info(gid);
idx_type = 'H5_INDEX_NAME';
order = 'H5_ITER_DEC';
for j = 0:root_info.nlinks-1
obj_id = H5O.open_by_idx(fid,'/',idx_type,order,j,plist);
obj_info = H5O.get_info(... |
function [CUM_SER,SER,Z_SER,IRF,ZIRF,LIRF] = FGLS_4lags_generate_restricted_8shocks(param,obs,restrict_v);
if restrict_v == 1;
param(7) = 0;
end
rho_d = param(1);
rho_q = param(2);
rho_p = param(3);
rho_w = param(4);
rho_g = param(5);
sig_eps = param(6);
%sig_eps = (1-rho)*sig_u;
%sig_eta = sig_u... |
function varargout = fillGraphFaces(varargin)
%FILLGRAPHFACES Fill faces of a graph with specified color.
%
% fillGraphFaces(NODES, FACES)
% draw the faces of a graph / mesh defined by a sef of vertices and a set
% of faces. The array NODES is a NV-by-2 or NV-by-3 array containing
% vertex coordinates. The arr... |
function n = getNFrames(this)
n = numel(this.xc1);
end |
function [ys_, params, info] = BC_19March2019_RBC_with_K_N_steadystate2(ys_, exo_, params)
% Steady state generated by Dynare preprocessor
info = 0;
ys_(6)=1;
ys_(5)=(1+params(6))*(1+params(1))+params(2)-1;
ys_(3)=ys_(5)*(1-params(4))/(ys_(5)/params(4)-params(2)-params(6))/params(4);
ys_(2)=ys_(3)*(... |
function intersect = intersectcount(node1,node2,R, origin,scale)
% this function tells you if the given line segment intersects with a shell
% of radius R (1) or not (0).
% r is the vector from root to current node
% v is vector from current node to next node
% R is the radius of sphere (scalor)
% t is the scalor th... |
clear
Q=[0.2 0.1 0.1 0.1; 0.1 0.3 0.2 0.1; 0.1 0.2 0.4 0.1; 0.1 0.1 0.1 0.8];
T=10000;
tmpu=normrnd(0,1,[1,T+length(Q)-1]);
y=zeros(1,T);
for i=1:T
y(i)=tmpu(1+i-1:4+i-1)*Q*tmpu(1+i-1:4+i-1)';
end
u=tmpu(4:end);
save('3_lag_quadratic_memory_task.mat','u','y','Q') |
function R = buildheader_stimex()
R.pipestamp = 'Stim_Ex_300617';
R.stimfreq = [0 5 130];
R.stimfrqname = {'0 Hz','5 Hz','130 Hz'};
R.condnames = {'0Hz','5Hz','130Hz'};
R.subnames = {'LN_C05','LN_C06','LN_C09','LN_C10','LN_C12','LN_C16','LN_C17','LN_C20','LN_C21','LN_C22','LN_C23','LN_C24'}; %
R.subDrug = {[0 1],[0 1... |
format long
clear all
clc
%vid = videoinput('winvideo');
%i = getsnapshot(vid);
i=imread('t2.dib');
imshow(i);
a=rgb2gray(i);
threshold = graythresh(a); % To compute a global threshold
BW = im2bw(a, threshold); % Converts grayscale image to Binary image
BW = ~ BW; % Inverts the image
imshow(BW)
%bw = imcont... |
% function pa_johnic_predict
home;
clear all;
close all;
clc
warning off;
%% IC
% d = 'E:\DATA\John_IC\predictions2';
% cd(d);
%% STRF
strfFiles = 'E:\MATLAB\PANDA\Spike\IC\strfbr0812.mat';
if ~exist(strfFiles,'file')
strfFiles = 'C:\MATLAB\PANDA\Spike\IC\strfbr0812.mat';
end
if ~exist(strfFiles,'f... |
classdef poly3 < ODR.roadPKG.planViewPKG.geometry
%POLY3 inherited class definiton for open drive in matlab
% contains the opendrive fromat with additional information
%
%----------------------------------------------------------------------
% BSD 3-Clause License
%
% Copyright (c) ... |
% University of Isfahan, Isfahan, Iran
% Computer engineering faculty
% Author: Seyyed Naser Seyyed Hashemi
% n.s.hashemi@eng.ui.ac.ir
% naser_seyed_hashemi@yahoo.com
%
% This function calculates VRTT for the topology stored in the array 's'.
%
%
%
functi... |
function acc = accuracy(theta, X, y)
m = size(X, 1);
p = zeros(m, 1);
for i = 1:m
prob = sigmoid(X(i,:) * theta);
if prob >= 0.5
p(i) = 1;
endif
end
acc = mean(double(p == y)) * 100;
end
|
classdef ImCache
% ImCache Wrapper class for caching microscopy images for faster viewing.
% The ImCache class attempts to cache recent and nearby images for faster
% loading on the CellTracking GUI.
%
% Written by: Michael M. Deng
% Last updated: 4/22/2016
properties
NBlocks
BlockSize
... |
%% Demonstration of the 2D Discrete Gram Transformation
%
% (C) 2013 Matthew harker and Paul O'Leary
% Institute for Automation
% University of Leoben
% A-8700 Leoben
% Austria
%
% email: office@harkeroleary.org
%
% This file produces a demonstration of the 2D discrete gram polynomial
% transformation of an ... |
classdef My < matlab.unittest.TestCase
methods (TestClassSetup)
function addBankAccountClassToPath(testCase)
p = path;
testCase.addTeardown(@path,p);
addpath(fullfile(matlabroot,'help','techdoc','matlab_oop',...
'examples'));
end
end
m... |
clc;
clear;
close all;
load Lung_data;
%% prepare data
d = 3;
n = zeros(d,1);
sp_data = cell(d,1);
sp_label = cell(d,1);
for dd = 1:d
sp_data{dd} = cleandata(CellRep == dd, :)';
[m, n(dd)] = size(sp_data{dd});
sp_label{dd} = Celltype(CellRep == dd);
end
%% sparate data
% remove ciliated... |
function [scaleddata] = scaling(traindata,lowvec,upvec)
[m,n]=size(traindata);
scaleddata=zeros(m,n);
for i=1:m
scaleddata(i,:)=-1+(traindata(i,:)-lowvec)./(upvec-lowvec)*2;
end
end |
function [rlt]=tccg(aa,bb)
%function [rlt]=tccg(aa,bb)
%
% This computes rlt of spike counts
% aa,bb are the vectors containing the spike counts
TEMP=[];TEMP1=[];
for i=1:length(aa)-1
temp=corrcoef(aa(1:end-(i-1)),bb(i:end));
TEMP=[TEMP temp(1,2)];
end
for i=1:length(aa)-1
temp=corrcoef(aa(i:... |
function [R_bc,Z_bc] = get_Hirshman_bc(zeta,Nrho,Ntheta,mode)
if(nargin<4 || mode==false)
mode=0;
end
[rho,~] = chebdif(2*Nrho,1); % Chebyshev r decreases from 1 to -1
theta = linspace(0,2*pi,Ntheta+1); theta = theta(2:end); % (1,Ntheta)
rr = reshape( rho * ones(1,Ntheta) , [2*Nrho,Ntheta] );
tt = reshape( reshap... |
function m = falsePosition(f, a, b)
% Solves for f(m)=0 over an initial interval [a,b].
i=0;
ym=1;
ya=f(a);
yb=f(b);
while(abs(ym)>eps)
m=a-ya*(b-a)/(yb-ya);
ym=f(m);
if ym*ya<0
b=m;
yb=ym;
elseif ym*yb<0
a=m;
ya=ym;
else
ym=0;
end
i=i+1;
end
|
% ----------------------------------------------------------------------------------------------------
% Display settings
%
close all;
set(0, 'defaultaxesfontsize' , 16 , ...
'DefaultTextVerticalAlignment' , 'bottom', ...
'DefaultTextHorizontalAlignment', 'left' , ...
'DefaultTextFontSize' ... |
#include "com_codename1_impl_ios_IOSImplementation_NativeImage.h"
const struct clazz *base_interfaces_for_com_codename1_impl_ios_IOSImplementation_NativeImage[] = {};
struct clazz class__com_codename1_impl_ios_IOSImplementation_NativeImage = {
DEBUG_GC_INIT &class__java_lang_Class, 999999, 0, 0, 0, 0, &__FINALIZER_co... |
y=1:10
x=4
plot(x,y) |
function urineOutput = urineOutput(heartrate,fluidBalance)
urineMaxPrDay = 15000;
urineMinPrDay = 500;
urineMax = dayToMinute(urineMaxPrDay);
urineMin = dayToMinute(urineMinPrDay);
if isnan(heartrate)|| isnan(fluidBalance)
urineOutput = (fluidBalance*0.75+urineMinPrDay)/24/60;
return;
end
if heartrate > 110
... |
%function [Eyeangle , ConfidentLevel]=detect_headpose(GrayImage,skinlevelmin,skinlevelmax,displaystatus)
function [Eyeangle , ConfidentLevel]=detect_headpose(GrayImage,displaystatus)
Eyeangle = 0;
ConfidentLevel = 0;
ImageHeight=size(GrayImage,1);
ImageWidth=size(GrayImage,2);
if (displaystatus == 1)
subplot(3,3,1)... |
%% Create Sample Currents
% This demonstration script shows how to intialize, use and delete objects
% deriving from the current class.
%% Creating a wire
% All wire objects inherit from the <matlab:doc('current') current> class,
% which is an
% <matlab:web(fullfile(docroot,'matlab/matlab_oop/abstract-classes-and-inte... |
close all; clear all; clc;
gmb= imread('./IF69D_Atividade_03_arquivos/gDSC04422.png');
m = size(gmb,1);
n = size(gmb,2);
p = m/4;
q = n/4;
X = gmb;
Y = reshape( X, [ p m/p n ] );
Y = permute( Y, [ 1 3 2 ] );
Y = reshape( Y, [ p q m*n/(p*q) ] );
I = double(Y);
I = sum(I,3)/16;
I = uint8(I);
subplot(1,2,1);
imshow(Y(:,... |
% Tanvir Ferdousi
% Kansas State University
% Last Modified: Aug 2018
% Copyright (c) 2019, Tanvir Ferdousi. All rights reserved.
% Redistribution and use in source and binary forms, with or without
% modification, are permitted
% Generates random population based on prescribed gender, age and sexual orientation
func... |
clear all
close all
Fs = 8192;
x = zeros(Fs, 8);
f = 1000:1000:8000;
n = 1 : Fs;
for i = 1 : size(x, 2)
x(:, i) = cos(2 * pi * n * f(i) / Fs);
sound(x(:, i), Fs);
pause(1);
end
|
% [X,g,c]=sc_readtsvfile('z:\Cailab\scTenifoldTime\Data\Cardiomyocytes\Cardiomyocytes.csv');
% T=readtable('Z:/Cailab/scTenifoldTime/Data/Cardiomyocytes/phenodata.csv');
[yes,idx]=ismember(c,T.X);
X=X(:,yes);
c=c(yes);
T=T(idx(yes),:);
%%
timepoint_levels = ["e14", "e18", "p0", "p1", "p4", "p8", "p11", "p14", "p15",... |
function par_est
% parameter estimation with derivatives Holzbecher September 2005
% for exponential fit of exponent lambda for c(0)=c0
global tfit cfit c0
% specify fitting data
tfit = [0.25 1 2 4 8];
cfit = [0.7716 0.5791 0.4002 0.1860 0.1019];
c0 = .8;
lambda = fzero(@myfun,0.11);
norm... |
clc
clear
close all
%% 参数设置
% 已知参数--》距离向参数
R_eta_c = 20e+3; % 景中心斜距
Tr = 2.5e-6; % 发射脉冲时宽
Kr = 20e+12; % 距离向调频率
alpha_os_r = 1.2; % 距离过采样率
Nrg = 320; % 距离线采样点数
% 计算参数--》距离向参数
Bw = abs(Kr)*Tr; % 距离信号带宽
Fr = alpha_os_... |
clear;
clc;
t = [-10:1:10];
%% Unit Impulse
impulse = t == 0;
subplot(1,3,1);
stem(t,impulse)
%% Unit Step
unitstep = t >= 0
subplot(1,3,2);
stem(t,unitstep)
%% Unit Ramp
unitramp = t .* unitstep;
subplot(1,3,3)
stem(t,unitramp)
%% Exponential
subplot(2,2,1);
stem(t,power(0.5,t))
subplot(2,2,2);
stem(t,power(2,t))
subp... |
function ztec = ztec_setup(ztec)
% ztec = ztec_setup(ztec)
%%%%%%%%%%%%%%%%%%%%
% Setup Ztec Scope %
%%%%%%%%%%%%%%%%%%%%
if nargin < 1
ztec = als_waveforms_setup('');
end
% MUX
if isfield(ztec.Device, 'MUX') && ~isempty(ztec.Device.MUX)
% Set the mux
setpv(ztec.Device.MUX.Ch1.Name, ztec.Device.MUX.Ch1.V... |
function I = generateHeschInput()
%GENERATEHESCHINPUT Generates Hesch trajectory, initial states, and true
%states, and map
I.x_init = [5, 0, 0]';
I.v_init = [0, 2*pi*5/60, 0]';
I.q_init = [-0.5, -0.5, -0.5, -0.5]';
I.T = 60;
I.dt = 0.25;
I.tVec = 0:I.dt:I.T;
I.trueInput = @trueInput;
mapFreq = 2*pi/36;
mapLo = -1;
map... |
function population=initPopulation(N,V)
%initPopulation(N,V)
population=rand(N,V);
end
|
set(groot, 'DefaultTextInterpreter','latex', 'DefaultLegendInterpreter','latex');
close all
clear
N = 100;
T = 100;
gamma = 0.6:-0.1:0.3;
s0 = [zeros(1, ceil(N/2)-1), 1, zeros(1, floor(N/2))];
cmap = [0.5, 1, 0.5; 1, 0.2, 0.2];
s = zeros(T+1, length(s0), length(gamma));
for i = 1:length(gamma)
s(1,:,i) = s0;
... |
alpha = 1;%defined by the problem in this case there is only d^2u/dx^2 so 1
endpoint = 1;%defined by problem in this case 1 b.c interval is [0,1]
m = 10;
h = .1;
k = .01;
Time = .5; % given in problem
lambda = (alpha^2)*k/(h^2);
g = @(x,t) exp(-(pi^2)*t)*sin(pi*x);
f = @(x) sin(pi*x);
i = (1/m):h:((m-1)/m);
w = zeros(f... |
% lab 3 task 1,2,3
clear all;close all;clc
% signal sourse
t = [0:0.1:10*pi];
signal = sin(t);
%% quantization block_2
level = 255;
step = 2/level;
partition = [-1+step/2:step:1-step/2];
codebook = [-1:step:1];
[quantized, QUANTV] = quantiz(signal, partition, codebook);
%% packetization block_3
k = 12... |
function [] =assign1_plots()
res1=zeros(20,30);
res2=zeros(20,30);
% This part of code generate 30 grpahs over vales {5,10,15,...,100}
for i=1:20
for k=1:30
res1(i,k)=assign1(i*5,1);
res2(i,k)=assign1(i*5,2);
end
end
% calculate avrage time simulation
t1_avg=sum(res1'... |
function [sim_data] = filt_tseries(sim_data,bands)
Data1 = sim_data.functional.data1.Data;
Fs1 = sim_data.functional.data1.Fs;
Nsegments = length(Data1);
Data_TS1 = cell(Nsegments,length(bands));
for band = 1:length(bands)
disp(strcat('-->> processing band: ', num2str(band)));
f1 = ... |
function y=dummybr(x,v)
% DUMMYBR
% DUMMYBR(x,v) creates a matrix of dummy variables corresponding to the elements of v
% x: Nx1 vector of data to be broken into dummies.
% v: (K-1)x1 vector specifying the k breakpoints (in ascending order) that
% define the k categories used to construct the dummy variables.
% y... |
%% preamble -- see lab wiki for explanation at:
% http://ctnsrv.uwaterloo.ca/vandermeerlab/doku.php?id=analysis:nsb2015:week1
clear all; pack
MASTER_root = 'D:\My_Documents\Dropbox\projects\Alyssa'; % replace this with home folder of your project
cd(MASTER_root);
MASTER_path; % reset and then set up path for this pro... |
function p = pcw_gss( t, s )
%PCW_GSS - First guess for the parameters of the Papadopulos Cooper solution
%
% Syntax: p = pcw_gss(t,s)
%
% p(1) = a = slope of Jacob straight line for late time
% p(2) = t0 = intercept of the Jacob straight line for late time
% p(3) = Cd = Dimensionless coefficient (1/2alpha)
%... |
function propiedadesGrafica=graficarInterfaces(nombreCompuesto, colorRGB)
strFuncionEvaluar=strcat("cte",nombreCompuesto);
charFuncionEvaluar=convertStringsToChars(strFuncionEvaluar);
numeroDevoluciones=nargout(str2func(charFuncionEvaluar));
%{
arregloIntermedio=zeros(1,numeroDevoluciones);
arregloIntermedio=feva... |
function [model_outp,vaf1,vaf2,model_interm,sse2]=lneval3(inp,h,pm,nltype,outp,plots,centeroutputflag,h_len2)
%[model_outp,vaf1,vaf2,model_interm,sse2]=lneval2(inp,h,pm,nltype,outp,plots,centeroutputflag,h_len2)
%run L-N model on input array to generate simulated output and measure
%against real output.
%
%use pm=0 to... |
function proj3_mrf_neighbours(y_all, y_all_stacked, sz, neighbours, i_component, str_components, nc, i_neighbours, single_beta, MHsigma2)
rng(0)
iterations = 1000;
burn_in = 300;
[theta, prior] = normmix_gibbs(y_all_stacked, nc);
[~, cl_ind] = normmix_classify(y_all_stacked, theta, prior);
% change to random field
z... |
function meanPressure = getMeanExperimentPressure(fileFullPath,varargin)
%获取一个实验excel文件的压力均值
sigmaTimes = 2.5;
if length(varargin) > 0
sigmaTimes = varargin{1};
end
rawData = loadExperimentPressureData(fileFullPath);
%为了去除异常值的影响,先过sigma滤波再求均值
for i=1:size(rawData,2)
tmp = rawData(:,i)
out_index = sigmaOutli... |
% L28 (with 2 zeros)
p1 = -19.9930 + 19.9930*i;
p2 = -19.9930 - 19.9930*i;
np=2;
nz=2;
k1 = 1.0;
% preamp with 4 pole 25Hz butterworth low pass (no zeros)
p3 = -145.175 + 59.9846*i;
p4 = -145.175 - 59.9846*i;
p5 = -60.1377 + 145.112*i;
p6 = -60.1377 - 145.112*i;
k2 = 608.807e6;
np=np+4;
% preamp contour filter, 4.5H... |
function AXstat =as_stats(myelinseg,pixelSize,myelin)
% AXstat=as_stats(myelinseg,pixelSize)
if ~exist('myelin','var'), myelin=1; end
myelinseg=reshape2D(myelinseg,1);
cc = bwconncomp(myelinseg, 8);
prop =regionprops(cc, {'Area', 'FilledArea'});
% Creation of a struct var for the stats
AXstat=struct('axonEquivDiamet... |
%
% This code demonstrates that the Fourier transform can be used to
% filter out the noise and reconstruct the original function.
%
clc
clear
clf reset
%
load data8.txt
%
N=size(data8,1);
t=data8(:,1);
f=data8(:,2);
%
y=fft(f);
ind=[0:N/2,-N/2+1:-1]';
%
for m=4:128,
m_array(m) = m;
y2=y.*(abs(ind)<=m);
f... |
clear
clc
close all
data = load('/Users/tyler/Dropbox/Data/Biosensors/NPNa_BSA_Titration/BSA_Blank/T2_D/4/dataRe.dat');
echoVector = (60:60:1024*60)*1e-3;
deltaVec = logspace(log10(15e-6),log10(815e-6),7);
gamma = 267.513e6; %s-1 T-1
GMHz = 1016; %MHz/m
gammaMHz = 42.576; %MHz T-1
G = GMHz/gammaMHz; %T m-1
DELTA = 1e-... |
%Calculate a matrix d_ji,m which is the smallest distance between f_j,m and any member of the set F_i
%
%Input:
% Cell array F,containing features for each image.
%Output:
% d = cell matrix,d{i,j} = distance between features between image i and j
% **d is not symmetric**
function [d] = get_distance(F)
num_images... |
% load the data
load lsfitexampledata
[N,M]=size(data);
% prepare the "quadratic regression matrix" A
% also known as the Vandermonde matrix
A = [ones(N,1),data(:,1), data(:,1).^2];
b = data(:,2);
% solve using least-squares
c = A\b;
% examine the fit
plot(data(:,1),data(:,2),'o',data(:,1),A*c)
grid on, titl... |
% Robin Touche 900610-3270 robint@student.chalmers.se
% Evaluates a polynomial from a vector
function value = Polynomial(x, inVector)
% Matlab uses descending order of coefficients
polynomial = fliplr(inVector);
value = polyval(polynomial, x);
|
function [fit_rez,parWithCorr] = I_on_sw2Peak(w2,u,parWithCorr,dk,dE,s,free_par)
%Calculate "exact" speen wave dispersion curve on the basis of approximated
%(parabolic) shape and the intensity of a speen wave along the dispersion
%curve on the basis of gaussian with background fittng
%
%
% the parameters of the parab... |
function [p0, p_fit, A1_fit, A2_fit] = ena_fit_twodetuning_fitCAL(w,Z,guess1, guess2,CAL)
% delta = wo-wl
% red: delta>0
% blue: delta<0
% WTJ, 20180921
w = w(:);
Z = Z(:);
n = length(Z);
n_smooth = round(n/50);
% amp_dB = smooth(db(Z(:)), n_smooth);
% phi = smooth(360*angle(Z(:))/2/pi, n_smooth);
Z = smooth(Z, n_sm... |
% This script moves through all of the Matlab files produced by process_init,
% and then will give a graphical presentation of the current clustering.
% The user is then asked to input 0 (yes) or 1 (no) to indicate if the clustering is OK.
%
% At the end, the matlab data file GraphOK.mat is created (with the recorde... |
%Gram-Schmidt reorthonormalization
%
%Algorithm:
% A = (a1,a2,...,an)
% After GSR, we get Q = (q1,q2,...,qn)
% 1. Normalize a1 as q1
% 2. Project a(k+1) on Span(q1,q2,...,qk), pk is accquired.
% 3. Normalize a(k+1)-pk we derive q(k+1)
% 4. Loop till the end.
%
%Author: Xiawei Huai
%Date: 2015/5/31
function... |
function [glmModel] = designMatrixBuilder_whisking(glmModel,glmnetOpt,selectedFeatures)
%selectedFeatures is a vector with values corresponding to the values in
%the DmatFields
for i = 1:length(glmModel)
end |
function [output1] = Jb_BaseRotX(var1)
if coder.target('MATLAB')
[output1] = Jb_BaseRotX_mex(var1);
else
coder.cinclude('Jb_BaseRotX_src.h');
output1 = zeros(6, 20);
coder.ceval('Jb_BaseRotX_src' ...
,coder.wref(output1) ...
,coder.rref(... |
clc
clear
x = [5 7 11 13 21];
y = [150 392 1452 2366 9702];
p = input('p=');
dely0 = (y(1)-y(2))/(x(1)-x(2));
dely1 = (y(2)-y(3))/(x(2)-x(3));
dely2 = (y(3)-y(4))/(x(3)-x(4));
dely3 = (y(4)-y(5))/(x(4)-x(5));
fprintf('dely0=%d\n dely1=%d\n dely2=%d\n dely3=%d\n',dely0,dely1,dely2,dely3);
delsqry... |
%% Description
% put |
clear all;
tol = 1e-3;
rng('default')
rng(1);
%% LASSO (288 problems)
id = 12570101;
o = profile_ops;
o.do_super_scs = 0;
profile_runner_lasso;
id = id + 1;
o.do_super_scs = 1;
profile_runner_lasso;
for mem = [10 100],
id = id + 1;
o = profile_ops;
o.memory = mem;
profile_runner_lasso;
end
for ... |
%% NICP test file
% just calculate the normal param
% just adjust the Ortation param
function NICPtestfile_normal_ortation( Refer_cloud,Match_cloud,Refer_Normal,Match_Normal )
%% 计算初始平移系数
[ Refer_cloud_l , ~ ] = size(Refer_cloud); %读取点云大小
[ Match_cloud_l , ~ ] = size(Match_cloud);
... |
% author : Philippe Vo
% date : 2019-October-22 14:56:56
% Lab Notes
% - need a report
% explained how to do report in the manual
%% Clearing
clc
clear
close all
%% Question 1
w_array = -pi:1:pi;
n_array = -10:1:10;
result = zeros(length(w_array));
for i = 1 : length(w_array)
result(i) = fourier_transform_w... |
function [z] = wyznacznik(a11,a12,a21,a22)
%funkcja liczy wyznacznik z macierzy 2x2
z =a11*a22-a12*a21
end
|
%Implements a graph cut based image segmentation algorithm
%
%Code wraps around a MATLAB wrapper (maxflow.m written by Michael
%Rubinstein) for a Max-flow/min-cut algorithm that implements
%Boykob-Kolmogorov's algorithm.
%
%-Might have to alter Rubinstein's code a bit to fully use features of the
%underlying alg... |
function [bw,T,status,xtraParams]=optThreshold(img,varargin)
% [bw,T,status]=optThreshold(img,varargin)
% perform thresholding of an image based on using defined algorithm
%
% Algorithm choice ('method'):
% {'minerr'},'otsu','kmeans','gm'
%
% Param (not all are aplicable to all methods)
%
% 'lvl' => 2^12... |
% Test af sfind
nstp=100;
a=[1 -1.5 0.7];
b=[1 0.5];
c=[1 0.8];
f=1;
d=1;
ms=idpoly(a,b,c,d,f,'nk',1)
fprintf('Generating estimation set \n');
u=prbs(nstp,15);
e=randn(nstp,1)*0.1;
y=sim(ms,[u e]);
%idplot([y u]);
Ze=[y u];
%Ze=dtrend(Ze);
fprintf('Generating test set \n');
u=prbs(nstp,15);
e=r... |
function plot_tfexp_bar(tfexp)
% Bar Graph
tfdir_all = {'mmm_1hz_all','mmm_2hz_all','mmm_4hz_all'};
tfdir_avg = {'mmm_1hz_avg','mmm_2hz_avg','mmm_4hz_avg'};
tfdir_ste = {'mmm_1hz_ste','mmm_2hz_ste','mmm_4hz_ste'};
epochs = {'TF1', 'TF2', 'TF3', 'TF4'};
figure();
for i = 1:3,
subplot(1,3,i);
hold on;
... |
function ieeg = trialIEEG(Trials, ch, field, bn)
%
% ieeg = trialIEEG(Trials, ch, field, bn)
%
% bn is in ms
global experiment DUKEDIR
IEEG_FS = experiment.processing.ieeg.sample_rate;
ieeg = zeros(length(Trials),length(ch),floor(diff(bn)*IEEG_FS./1e3),'single');
%pause
for iTrial = 1:length(Trials)
Subject = Tri... |
function [y] = naive2(P,x)
[l,c]=size(P);
V = ones(l,l);
for j=1:l
V(:,j) = P(:,1).^(j-1);
end
alpha = V\P(:,2);
y=zeros(size(x));
for i=1:l
y =+ alpha(i)*x.^(i-1);
end
plot(x,y);
end
%P=[-2 4; 0 0; 1 1];
%y=naive2(P,[-1 0 2]) |
% P = graph2pedm(G)
%
% Transforms a n x 3 array graph G, with weight({G(1),G(2)})=G(3),
% into a partial Euclidean distance matrix P
function P = graph2edm(G)
[m,t] = size(G);
n = max(max(G(:,1)),max(G(:,2)));
P = zeros(n);
for i=1:m
P(G(i,1),G(i,2)) = G(i,3);
P(G(i,2),G(i,1)) = G(i,3);
end
end |
A = [4 6 10; 6 25 19; 10 19 62];
B = [4 6 10; 6 13 19; 10 19 62];
disp("------- Matrix A -------")
disp("My implementation:")
L = cholesky(A);
disp(L);
disp("True solution:")
Ch = chol(A, 'lower');
disp(Ch);
disp("------- Matrix B -------")
disp("My implementation:")
L = cholesky(B);
disp(L);
disp("True solution:")
C... |
function [] = RecipEntropySpicesConsolidateAll(Ningred_used,consolidate_orders,Nsubsamps)
% Consolidates maxent data for Ningred_used most common spices
%
% Written by: DJ Strouse
% Last updated: Aug 22, 2013 by DJ Strouse
%
% INPUTS
% Ningred_used [=] positive integer = number of spices to use
% consolidate_orders [=]... |
function intersects=segcirc(p1,p2,o,r) % This function could result bugs.
% SEGCIRC calculates intersecting points of a line segment and a circle.
% P1 and P2 are both 2*1 dimensional vectors defining the line segment.
% O is a 2*1 dimensional vector of the central point of the circle.
% R is the radius.
% This functio... |
clear;load ..\W
y(1:50) = W(:,3,replace({'TEPRB'}));
x = 1960:2009;
fun = @(c,x)c(1)./(1+exp(c(2).*(x+c(3))))+c(4);
options = optimset('MaxFunEvals',2000);
c0 = [6e6,-0.03,-1885,-3.5e6];
c = lsqcurvefit(fun,c0,x,y,[],[],options)
figure
plot(x,y);
hold on;
plot(x,fun(c,x));
legend('original','predict')
ylabel('Billion B... |
function p_vec = bisection_func(f,a,b,Nmax)
%BISECTION_FUNC Bisection Method
% p_vec = BISECTION_FUNC(f,a,b,Nmax)
% computes the vector of approximations p_vec
% obtained by the bisection method
% applied to function f,
% using Nmax iterations,
% and interval [a,b].
% Write your code here |
function [ result ] = truncateImage( origin )
%TRUNCATEIMAGE Cuts off the lowest 25 pixels of the image
%
% IMG = truncateImage( origin ) cuts off the lowest 25 pixels of the
% provided RGB-Image in order to remove the Google logo and
% returns the result.
%
% cut the lowest ... |
%Copyright 2013 The MathWorks, Inc.
% These are the files we want to build.
files = {
'applyScaleFactors'
}';
% Check that we are running Windows.
assert ( ispc() )
% Check if we are running 32 or 64 bit MATLAB.
bittedness = 32;
if ( strcmp( computer, 'PCWIN64' ) )
bittedness = 64;
end
... |
%Ruifeng Zhang 861212163
%CS 171 PS2
%29 October 2017
function w = learnlogreg(X,Y,lambda)
X = [ones(size(X,1),1) X];
n = 0.1;
m = length(Y);
w = zeros(size(X,2),1);
while true
g = 0;
for i = 1:m
if Y(i)==0
Y(i) = -1;
end
p = 1/(1+exp(-(Y(i)*w'*X(i,:)')));
... |
close all;
clear all;
N = 128; % Number of nodes
fprintf(1, 'Starting simulation with %d nodes\n', N);
s = rand(N,1);
sB = rand(N,1);
simMax = 25;
SAMPLES = 28;
START_POINT = 0;
END_POINT = 1;
tTable = []; % Convergence Time
qTable = []; % Q Average Max Eigenvalue
parfor pI = 1:SAMPLES
pChoice = linspace(START... |
function A=Build_Min_Heap(A)
% 函数功能:将A数组排列为最小堆(min heap)结构。
n=length(A);
for i=n/2:-1:1
A=Min_Heapify_Recursive(A,i,n);
end |
%% Random data
clear, clc, clf
rng(2021)
X = randn(50,500);
mean_vector = mean(X,2);
X_zero_mean = X - mean_vector;
covariance_matrix = cov(X_zero_mean');
[V,D] = eigs(covariance_matrix, 50);
eigen_values = diag(D);
RMSD = zeros(49,1);
for i=1:49
E = V(:, 1:i);
z = E'*X_zero_mean;
X_hat = E *... |
% Title : The perceptron algorithm
% Description :
% This code contains the solution of the perceptron with the original learning algorithm
% See also :
% - Function_tanh
% - Function_Cost_Perceptron
% - Function_Cost_Perceptron
% - Function_plot_result
% - Function_plot_CostPerceptron1D
clear; cl... |
% Решение уравнения теплопроводности методом сеток
% du/dt = a * (d^(2)u / dx^(2)) + f(x,t)
% Parameter's initialization
f = @(x,t) -x*(1-x)/(10+t)^2 + 2/(10+t);
ux0 = @(x) cos(0.5*x) + x*(1-x)/10;
u0t = @(t) exp(-0.25*t);
u1t = @(t) exp(-0.25*t)*cos(0.5);
result = @(x,t) exp(-0.25*t)*cos(0.5*x) + x*(1-x)/(10+t);
a... |
function writeBigTiff(varargin)
% BigTiff Writer with Single Precision.
% Input : argument 1: Image Matrix or Image Stack Matrix
% argument 2: Path to file
% argument 3: Overwrite function
% Input Image matrix is automatically converted to Single
% If 3rd argument is 'overwrite', than t... |
% Auto generated function to execute the generated cosimulation test bench
%
% Generated by MATLAB 8.4 and HDL Coder 3.5
function run_hdl_matmul_cosim
% Launch HDL simulator
disp('### Launching ModelSim for cosimulation ');
launch_hdl_matmul_cosim;
% Wait for HDL simulator to ready
disp('### Waiting for ModelSim to... |
%gain stage
VT=25e-3;
BFN=178.7;
VAFN=69.7;
RE1=100;
RC1=1000;
RB1=78000;
RB2=18000;
VBEON=0.7;
VCC=12;
RS=100;
C1 =450e-06;
C2 =450e-06;
Cout = 200e-6;
vi = 0.01;
printf("valores_intro_TAB\n");
printf("Cin = %e \n", C1);
printf("CE = %e \n", C2);
printf("Cout = %e \n", Cout);
printf("R1 = %e \n", RB1);
printf("R2 = ... |
% logregGradeResiduals
%[X, y, bs, perm] = logregGradeMH();
N = length(perm);
figure;
% posterior predictive residuals A&J p97
for ii=1:N
i = perm(ii);
p1s = 1 ./ (1+exp(-X(i,:)*bs')); % p1s(s) = p(y=1|x(i,:), bs(s,:))
p1 = mean(p1s); p0 = 1-p1; ppred = [p0, p1];
ppredobs(i) = ppred(y(i)+1); % 0,1 -> 1,2
h... |
function new_pose = VehicleModel(v,w,previous_pose)
% **********************************************
% ----------- VEHICLE MODEL -----------
% DESCRIPTION:
% - Mimic real world respond
% ARGUMENT:
% v : foward speed
% w : rotation speed
% previous_pose : [X, Y, Theta]'
%
% RETURN:
% X... |
function [DeltaU, lambda] = myQP(H,q,G,Wtilde,lam0)
% This function implements the dual projected gradient algorithm for
% solving a QP problem. Minimize 1/2*U'*H*U + q'*U subject to G*U <= Wtilde
% set the initial guess of lagrange multipliers.
lambda = lam0;
% form the quadratic term with respect to lambda of the ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.