text stringlengths 8 6.12M |
|---|
%% define basic parameters
close all; clear; clc;
nr = 151; % no. of points in r direction
nz = 1681; % no. of points in z direction
zmin = 0; zmax = 1.4e-2; % computational domain in z direction [m]
rmin = -0.125e-2; rmax = 0.125e-2; % computational do... |
function [ means, variances ] = K_means_2( sub_image )
%K_MEANS_2 Summary of this function goes here
% Detailed explanation goes here
means = [0, 0];
variances = [0, 0];
ownership = zeros(size(sub_image));
[rows,cols] = size(sub_image);
init_centroids = [min(min(sub_image)),max(max(sub_image))];
init_delta = 10;
... |
c = clock;
t = c(4)*10000 + c(5)*100 + floor(c(6));
for i = 1:t
randi(t);
end
%rand(1) |
function rectified_sig=Waveform_Rect(encoder_sig)
% Copyright@ vastera@163.com
% General introduction:Rectify the waveform of encoder signal from elipse into circle
% Referece: "New intertpolaion method for quadrature encoder signal"
%% ====================== INPUT ========================
% encoder_sig: Type:... |
t = 4;
g = 11;
dmax=10;
% Load in and collect graphs.
% graphs is a 1-by-g cell of graphs.
graphs = cell([1 g]);
neighbors = cell([1 g]);
lowords = cell([1 g]);
for j = 1:g-1
fn = ['GRG4d-988v-2454e-' num2str(j) '.mat' ]
load(fn,'graph','points','neighborcounts');
graphs{j} = graph;
num_nodes = size(g... |
%writing a very basic routine to solve the coupled ODE:
% T' = N'/N + T
% N' = T^{3/2} N
%
% Which we can simply rewrite as:
% T' = T^{3/2} + T
% N' = T^{3/2} N
% That's not so terrible. Can do both an explicit and implicit
% solve method.
|
function output_image = Problem2b_JJN()
%% ------------------------------------------------------------------------%
% EE 569 Homework #3
% Date: Nov. 1, 2015
% Name: Faiyadh Shahid
% ID: 4054-4699-70
% Email: fshahid@usc.edu
%------------------------------------------------------------------------%
%% Reading the file... |
%verify if the method of generating valid Vt vectors from img(I) is valid
while true
for nt = 1:10
for nr = 1:10
n = nt+nr;
%generating Z components
w = 2*pi*(100000 + 1000000*rand);%angular frequency
M = zeros(n);%inductance
for i=1:n
for j=i+1:n
M(i,j) = rand/1000000;
end
end... |
function grad = igrad_logistic(x, i, W, Y)
w = W(i,:);
y = Y(i);
v = exp(-y* (w*x));
% grad = (-y*v) /(1 + v) *(w');
grad = (-y) /(1 + 1/v) *(w');
|
function QP = chillerOnly1step(QP,marginal,FirstProfile)
% update the equalities with the correct demand, and scale fuel and electric costs
% EC is the expected end condition at this time stamp (can be empty)
% StorPower is the expected output/input of any energy storage at this timestep (can be empty)
% MinPower and M... |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Optical Flow
% Cristian Duguet
clc
close all
clear all
% Gravitational Constant
G = 9.80665;
% Experiment name
experiment_date = '20120718_2021';
% experiment_date = '20120704_1913';
%% General Parameters:
%metrics in mm
sigmaIMUacc =... |
function CoM=getCoM(gh,g_leg,leg_act,alpha)
load('robot_para.mat')
F=@(L) [eye(2),[L;0];0 0 1];
R=@(a)[cos(a),-sin(a),0;sin(a),cos(a),0;0,0,1];
for ind=1:4
if leg_act(ind+4)==0
g_leg{ind}=g_leg{ind}*F(l_e*3/4);
end
end
CoM=[0;0];
% for ind=1:4
% CoM=CoM+1*gh{ind}(1:2,3);
% CoM=Co... |
function W = AirCalRoutine_MKeditAmpCalW(PSG_delta,PSG_theta,PSA_delta,PSA_theta,PSA_LP,nSteps)
% nSteps = input(64); %Last inputvec scalar is the measurement #
ThetaMotorGen = (0:nSteps-1)*2*pi/nSteps;
ThetaMotorAna = 4.9*ThetaMotorGen;
%OUTPUT VARIABLE lambda x measurements x 1 x 1
Irrad=zeros(1,nSteps,500,500);
... |
function out = GGPaugloglikel(cnts, u, eta, sigma, c)
n = sum(cnts);
out = (n-1)*log(u) - GGPpsi(u, eta, sigma, c) - gammaln(n);
out = out + length(cnts)*(log(eta) - gammaln(1-sigma));
out = out + sum(gammaln(cnts-sigma) - (cnts-sigma)*log(u + c));
end
|
function [ pattern ] = createTemplate( data , namePattern )
%CREATETEMPLATE Given the samples in the data matrix, create a template
%using the namePattern method.
switch namePattern
case 'grayscaleMean'
%mean of the grayscale images
pattern = squeeze(mean(data));
... |
n=randn(size(imL,1),size(imL,2));
m=zeros(length(Lx),1);
for i=1:length(Lx)
x=Ly(i);
y=Lx(i);
m(i)=n(x,y);
end |
function [imu, sf] = imuscale(imu, t, w, f)
% Scale gyro(acc) to given angular rate(force) at time t, such that
% [w; f]'*ts = imu(k,1:6) .* sf' .
%
% Prototype: imu = imuscale(imu, t, w, f)
% Inputs: imu - SIMU data array
% t - specific time
% w/f - given angular rate(force)
% Outputs: imu - SIMU data ... |
%Function to compute continuous time fourier transform
function [X] = continuousFT (xt,t,a,b,w)
%defining symbolic var t
syms t;
X=int(xt * exp(-1i*w*t),t,[a b]); %expression for cont. t FT
end |
function [epsr,mur,sigma] = fdtd_profile(profile, N, b, varargin)
epsr = ones(N,1);
mur = ones(N,1);
sigma = zeros(N,1);
if (profile == 0)
% eps = eps_o, mu = mu_o, sigma = 0.
return
end
for i = 1:N
if (profile == 1) % Permittivity discontinuity
if i >= b
epsr(i) = 9;
... |
clear all
a0=[2 3;6 4];
a1=[-10 1;-20 3];
a2=[1 3;5 2];
syms p1 p2 p3 p4 p;
p=[p1 p2;p3 p4]
%二次矩阵方程是:p^2*a2+p*a1+a0=0;
eq=p^2*a2+p*a1+a0;
[p1,p2,p3,p4]=solve(eq(1,1),eq(1,2),eq(2,1),eq(2,2),p1,p2,p3,p4);
p1=double(p1)
p2=double(p2)
p3=double(p3)
p4=double(p4)
t=1;
[m,n]=size(p1);
pp=zeros(2,2,m);
f... |
%
% This function performs spectrally resolved Granger causality using the
% non-parametric spectral matrix factorization of Wilson, as implemented
% by Dhahama & Rangarajan in sfactorization_wilson. Both standard and
% conditional Granger causality are attempted.
%
% FieldTrip code being used is a recent download zip... |
% EJERCICIOS RESUELTOS DE VISIÓN POR COMPUTADOR
% Autores: Gonzalo Pajares y Jesús Manuel de la Cruz
% Copyright RA-MA, 2007
% Ejercicio 13.4: Movimiento
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 13.5.1 Flujo óptico
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%... |
function m_Tracc = f_HomogTracc(e_DatSet,e_VarEst,e_VarAux,m_ElemLoc,facNormMicro,longFis,e_VG)
nDime = e_VG.ndime;
nTens = e_VG.ntens;
%Se asume que se está pasando los datos del PG (el 6 normalmente) sobre el que se quiere hacer el cálculo.
m_Tracc = zeros(nDime,1);
m_NormalMicro = zeros(nTens,nDime);
nSe... |
function numero = devolverNumero()
numero=123;
endfunction
|
N = 1000;
K = [5,10,25,50,100];
for i = 1:length(K)
k = K(i);
rank = RandWebRank(N,k);
% empirical distribution
L = length(rank);
X = sort(rank);
Y = (1:L)/L;
plot(X, Y);
hold on
end
hold off |
function [dataCell, fileNames] = packagePairsebFRET(channels)
%called by Kera.ebfretImport inside Kera.m
%a function which takes in multiple ebFRET output files and extracts the
%data from them, keeping the traces in the correct order to pair the
%corresponding traces with each other
%dataCell is a cell containing b... |
function g = sigmoid(z) %z is theta transpose times x
%SIGMOID Compute sigmoid function
% g = SIGMOID(z) computes the sigmoid of z.
% You need to return the following variables correctly
g = zeros(size(z)); % must work on a matrix
if numel(z)>1
for i=1:numel(z)
g(i)=1/(1+exp(z(i)*-1));
end
... |
function y = SurfaceStress( Model, Parameters, Exp, Stretch, Rotation)
% SurfaceStress( Model, Parameters, Exp, Stretch, Rotation) returns real
% Cauchy Stress for a given experimental protocol "Exp" projected onto the
% respective readout-surface. The protocol may be altered by a rotation
% "Rotation" of the prepare... |
function S = zzscb_space(A,B,C,D,flag,dc,tol,lambda)
%SCB_SPACE Geometric Subspace from SCB
%
% S = zzscb_space(A,B,C,D,flag,dc,tol,lambda)
%
% Including: v_star v_minus v_plus s_star s_minus s_plus r_star n_star s_lambda and v_lambda.
if nargin==5,
dc=0;tol=1e-8;lambda=0;
elseif nar... |
function ret = nonLin(u,sigma)
% A short function for the nonlinearity in the given Schroedinger equation.
% ret = nonLin(u,sigma) = absSq(u).^sigma.*u;
ret = absSq(u).^sigma.*u;
end |
function [J, grad] = costFunctionReg(theta, X, y, lambda)
%COSTFUNCTIONREG Compute cost and gradient for logistic regression with regularization
% J = COSTFUNCTIONREG(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. ... |
function varargout = editmotion(varargin)
% EDITMOTION MATLAB code for editmotion.fig
% EDITMOTION, by itself, creates a new EDITMOTION or raises the existing
% singleton*.
%
% H = EDITMOTION returns the handle to a new EDITMOTION or the handle to
% the existing singleton*.
%
% EDITMOTION('CALL... |
function z=f(r,a,n)
% Lab #2 - Ex2.b
e=0:1:n;
R=r.^e;
z=a*sum(R);
end |
function intval = compGauss3(f,a,b,n)
% function intval = compGauss3(f,a,b,n)
% Composite 3-point Gaussian integration rule for computing
% integral of f(x).dx from x = a to x = b with the simple
% 3-point Gauss rule applied to each of n pieces:
% integral f(x).dx from x_i to x_{i+1}.
intval = 0;
h = (b-a)/n; % ... |
function plot_cheby6(low, high)
X = linspace(low, high, 100);
for i=1:length(X)
Y(i) = cheby6(X(i));
end
plot(X, Y)
end
|
function [Aperp,Apar] = perpcomponent( A, n )
% perpcomponent.m - finds perpendicular (and optionally) parallel
% components of a vector relative to a reference vector.
%
% Usage:
% perp_component = perpcomponent(A,n)
% [perp_component,parallel_component] = perpcomponent(A,n)
%
% where n is the reference vector.
... |
function [modelaud modellyr] = svm_predict_libsvm_lyrics_and_audio_v2(lyrics_c, lyrics_g, audio_c, audio_g)
%{
%Yt_pred_prob_estimates_aud
Yt_pred_prob_estimates_lyr
Yq_pred_prob_estimates_aud
Yq_pred_prob_estimates_lyr
%}
% save the scaling and the model
%% you come in with the parameters for the two SVM's
%% for... |
velspec = fpspec_simdata;
fpspec = velspec / SC.lambda; |
function err = mat_wind_flux_div_test
disp('mat_wind_flux_div_test')
% test mesh with a hill terrain
% X = uniform_mesh([2,2,2],[.5,.5,.5]);
X = regular_mesh([3,4,5],[0.1,0.1,0.5],1.2);
X = add_terrain_to_mesh(X,'hill','squash',0.4);
% matrix of wind flux divergence
DM = mat_wind_flux_div(X);
% random test wind
U = gra... |
function cul_vec = cul_sum(v)
% this function calculates the culmulative sum
% v: vector of numbers.
cul_vec = [];
sum = 0;
for i = 1:length(v)
sum = sum + v(i);
cul_vec = [cul_vec, sum];
end
|
function hrsw = bwrswSM(data,piflag,xgridp,eptflag)
% BWRSW, Ruppert Sheather Wand Plug In (Binned version), for 1-d reg.
% Steve Marron's matlab function
% Does data-based bandwidth selection for 1-d local linear reg.
% estimation, using the Ruppert Sheather Wand Plug In method.
% A linear binned i... |
function plotTrajBest(clrs, trajData, labels, countTraj)
classes = unique(labels);
for ci = 1:length(classes)
inds{ci} = find(labels==classes(ci));
closest{ci} = getClosestTrajectories(trajData, inds{ci}, countTraj);
for k=1:length(closest{ci})
plot3(squeeze(trajData(1,:,closest{ci}(k))), squeeze(trajData(... |
clear; close all; fclose all; clc;
%________________________________________________________________________________________________
tx_pos = 9; % options 1->9
z_rx = 165+100j;
% Testcase for Tx positioning
switch tx_pos
case 1
z_tx = 300+240j;
case 2
z_tx = 165+240j;
case 3
... |
clear all
close all
clc
%% Constantes
N=30;
x=linspace(-2.5,2.5,N);
y=linspace(-2.5,2.5,N);
m1=60;
s1=8;
m2=140;
s2=6;
m3=10;
s3=5;
variables=3;
%creacion de la imagen
im=zeros(N,N);
for k=1:size(im,1)
for j=1:size(im,2)
if(sqrt(x(k)^2+y(j)^2)<2)
if(sqrt(x(k)^2+y(j)^2)>1)
... |
% Name: Zheng Wen
% USC ID: 7112807212
% USC Email: zwen1423@usc.edu
% Submission Date 1/27/2020
clc
clear all;
G = readraw('E:\Chrome Download\EE569\Week1\HW1_images\Toy.raw');
[G_Red, G_Green, G_Blue] = raw23D(G,400,560);
G_Red = matTranspose(G_Red);
G_Green = matTranspose(G_Green);
G_Blue = matTranspose(G_... |
clear all
close all hidden
clc
warning("off")
%% Input data parameters: path to folder containing
%% the analytical data and to folder containing
%% the operational data.
query_analytical_data = "analyt/dataAM.csv";
query_operational_data = "oper/dataOper.csv";
base_dir = "../source_data/";
%% Splitting parameters
... |
a=1:256;
figure
imshow(a);
|
function f = f_fil_2D(S,B,P)
% Calculate filament force
f = zeros(P.K,2);
if ~isempty(P.a_points)
[x1,x2] = meshgrid(S(:,1),S(:,2));
x_diff = x1' - x1;
y_diff = x2 - x2';
d = sqrt(x_diff.^2 + y_diff.^2);
W = (P.alpha/(P.sigma*sqrt(2*pi)))*exp(-(d.^2)./(2*P.sigma^2));
... |
function tdata = timeplot5(path, root, index )
% function result = timeplot5(path,root, index)
%
% Returns the intensity of the voxel the point determined by the index
%
%
oldpath=pwd;
cd (path);
files = dir(strcat(root,'*.img'));
if (size(files)==[0 1])
tdata=0;
fprintf('\n** ERROR: %s ----- images not found **... |
function res = opdracht_7_versie_1_CHECK(apStudentSol)
%%========== PLACE SOLUTION IN COMMENTS HERE
% % % % % % % % % % % % % function output = opdracht_7(input)
% % % % % % % % % % % % %
% % % % % % % % % % % % % if isequal(input,1)
% % % % % % % % % % % % % output = 66:99;
% % % % % % % % % % % % % elseif iseq... |
%MLData = PatientsData;
for i = 1:5
brains = MLData(i).brain_pos;
annotations = MLData(i).annots;
pos_idx = MLData(i).pos_idx;
pid = MLData(i).Pid;
dataset = MLData(i).Datatype;
imgs = NormalizedImage_pid(pid, MLData(i).pos_idx, 'Protected');
mask = zeros(size(brains));
for target ... |
function Z = zcr(signal,windowLength, step, fs);
signal = signal / max(abs(signal));
curPos = 1;
L = length(signal);
numOfFrames = floor((L-windowLength)/step) + 1;
%H = hamming(windowLength);
Z = zeros(numOfFrames,1);
for (i=1:numOfFrames)
window = (signal(curPos:curPos+windowLength-1));
window2 =... |
image = imread('24_rectangle.jpg');
Ar= double(image(:,:,1));
Ag= double(image(:,:,2));
Ab= double(image(:,:,3));
[M,N] = size(Ar);
A = zeros(M,N);
for i=[1:1:M]
for j=[1:1:N]
r=(Ar(i,j));
g=(Ag(i,j));
b=(Ab(i,j));
A(i,j) = double(r*(2^16))+double(g*(2^8))+double(b);
... |
function cxi=bldcxi(cxi0,prnlist,cdate,ocdate,ipnoise)
%
% Function bldcx
% ==============
%
% Build the L1/L2 constraint matrix for a list of PRN's. It actually
% starts with cx=cx12 and then keep destroying the matrix,
% eliminationg prns that are not in the prn list until the elements
% ... |
function [F, dFdu] = JENK2FORCE(ut, pars)
Fs = pars(:, 1);
Kt = pars(:, 2);
PhiMx = Fs./Kt;
F = (Kt.*ut).*(abs(ut)<PhiMx) + ...
(Fs.*sign(ut)).*(abs(ut)>=PhiMx);
i = length(find(abs(ut)>PhiMx));
disp([num2str(i) ' Slipped.'])
dFdu = (Kt).*(abs(ut)<PhiMx);
F = re... |
function [r] = Lattice2D(a, siz, type)
%
periodicity = true;
sq2 = sqrt(2);
if strcmp(type, 'sq2') || strcmp(type, 'hex')
ri = [0,0; 1/2, 1/2];
elseif strcmp(type, 'sq')
ri = [0,0];
else
error('Type selected invalid. Only types "sq" and "sq2" are available')
end
r0 = ri;
[n1, n2] = size(ri);
for i = 0:si... |
function [] = plot_raw_corr(corrMatrix, save)
figure()
imagesc(corrMatrix)
xlabel('Cell Number')
ylabel('Cell Number')
title('Raw Correlation Across Cells')
colorbar()
if save
saveas(gcf,'./Raw-dfbyF-corr.png');
saveas(gcf,'./Raw-dfbyF-corr.fig');
end
end
|
function runStandingWaveInAClosedBasin
close all;
clear, clc;
Nz = 1;
NL = [1 2 3 4 5 6];
[ ErrOrder1, TimeOrder1 ] = runSimulations( Nz, NL);
disp('=======Errors for order 1================')
disp(ErrOrder1)
disp('=======End errors for order 1================')
disp('=======Times for order 1================')
disp(Ti... |
function D_hat = hypothesis_filter(D, I, sigma_color, alpha_spacial, cost_thr)
if nargin < 3
sigma_color = 0.01;
end
if nargin < 4
alpha_spacial = 0.88;
end
if nargin < 5
cost_thr = 3;
end
maxdisp = ceil(max(D(:)));
mindisp = floor(min(D(:)));
layers = maxdisp - mindisp + 1;
[h, w] = size(D);
... |
clear; % 清除上次执行工作区痕迹
userCount = 30;
serverCount = 10;
iterationnum = 20;
delta = 0.001; % 相等允许的误差范围
nodeCountList = zeros(1,userCount)+10; % 每个用户都有10个子任务
nodeCountMax = max(nodeCountList);
taskDAG = zeros(nodeCountMax,nodeCountMax,userCount);
taskDAG(:,:,1) = [0,-1,-1,-1,-1,-1,0,0,0,0;1,0,0,0,0,0,0,-1,-1,0;1,0,0,... |
l=100;
wc = pi/16;
xn = zeros(2*l, 1);
syms w
for n=-l:l
xn(n+l+1) = (1/(2*pi)).*int(exp(1i.*w*n), w, -wc, wc);
end
figure;
n=-l:l;
plot(n,xn);
title('Inverse DTFT (wc=pi/16)')
xlabel('n')
ylabel('x[n]')
%x[n] is expected to a real sinc function and we can see that our plot
%matches this expectation.
%We ca... |
function [quotient, remainder] = binPolyDiv(dividend, divisor)
% Divides binary polynomials
% Uses polynomial long division
if ~any(divisor, 2)
%throw(MException('binPolyDiv:divByZero', 'Division by zero polynomial'))
fprintf('WARNING: Division by zero polynomial\n');
end
coder.varsize('remainder', [1 inf], [f... |
function [colorHex] = constructHexColorForKml(color, alpha)
%CONSTRUCTHEXCOLORFORKML Construct a hex color variable for plotting in a
%.kml file. All input values, including elements of [r, g, b] color and
%alpha, are 0~255 integers.
%
% Yaguang Zhang, Purdue, 02/10/2021
if ~exist('alpha', 'var')
alpha = 255;
end
... |
function gencolors(mapfile)
%mapfile='MNI_BNatlas/MNI_BNatlas.txt';
cachedir = 'cache/';
%% load image {im0,im1,im2}
load([cachedir 'imgseq-xyz.mat'])
%% load labels
fp=fopen(mapfile,'rt');
labels={};
while 1
l=fgets(fp);
data=strsplit(char(l),' ');
if size(data{1})<1,break;end
idval=str2num(data{1});
labels{idval}=... |
clear all
[status,id]= system('whoami');
str_user= id(1:end-1);
check_if_iam_using_the_ihuserver(str_user);
[ str_network_imagerie, str_network_perso ] = get_network_name( str_user );
% filename='/home/valery/generic_spirit_random_cine.h5'
filename=['/home/',str_user,str_network_imagerie , '/DICOM_DATA/2017-10-31... |
function [data head]=raw_load_chipod(filnam)
%
% function [data head]=raw_load_chipod(filnam)
%
% read chipod data structure
%
% Modified 4/11/05 to read 65Hz data
% Modified 05/10/07
% Modified 05/24/10 to read Chipod2
% Modified 12/21/10 to read MPChipod2
% global data head
% $Revision: 1.12 $ $Date: 20... |
function [gamma_sum] = calc_gamma_sum(gamma_sum,nstates,length,alpha,beta)
for t = 1:length
for i = 1:nstates
gamma_sum(i) = single(gamma_sum(i) + alpha((t-1) * nstates + i) * beta((t-1) * nstates + i));
end
end
end
|
clear all;
load EigenEnergy.mat;
load EigenVector.mat;
load n.mat;
load CubicSize.mat;
nx=nx/2; ny=ny/2; nz=nz/2;
load index.mat;
Ep=14.0;
for i=1:5
for j=1:5
deltaE(i,j)=Ee(i)-Eh(j);
osc_str(i,j)=(Ep/deltaE(i,j))*abs(sum(Ve(:,i).*conj(Vh(:,j))))^2*Volume;
end
end
refractive_... |
classdef QuoteMap < handle
% QuoteMap 作为一种容器来维护(code, quote)键值对,通过code可以方便的查找到对应的Quote
properties
mp;
end
methods
function [obj] = QuoteMap()
obj.mp = containers.Map('KeyType', 'char', 'ValueType', 'any');
end
end
methods
function [obj] = add... |
clear all, format long
%a0 är derivatan i (0,310) alltså i vår startpunkt, hur kan fzero ge oss
%detta? Den försöker hitta en funktion där slutfelet är noll: Kan se felet som
%en fuktion och vill hitta dess nollställen där felet är noll.
%a0 är nollställe för slutfelet?
options = odeset('RelTol',1*10^(-10), 'AbsTol',... |
% Software: Gaussian Elimination Algorithm
% Author: Hy Truong Son
% Position: PhD Student
% Institution: Department of Computer Science, The University of Chicago
% Email: sonpascal93@gmail.com, hytruongson@uchicago.edu
% Website: http://people.inf.elte.hu/hytruongson/
% Copyright 2016 (c) Hy Truong Son. All rights r... |
function [Dmc,C] = dbminuscontrol(varargin)
% dbminuscontrol Create simulation-minus-control database.
%
%
% Syntax
% =======
%
% [D,C] = dbminuscontrol(M,D)
% [D,C] = dbminuscontrol(M,D,C)
%
%
% Input arguments
% ================
%
% * `M` [ model ] - Model object on which the databases `D` and `C... |
function writeinput(var_str,var_val,input_path)
%WRITEINPUT This is a utility for replacing input values in a current
%LESinputs.txt file.
%
%WRITEINPUT(string,value,path) replaces the input designated by
%'string' with 'value'. 'input_path' specifies the absolute or relative path to the
%LESinputs.txt file. By defaul... |
function [newX, newY]= rotatepolygon(x, y, angle,midX,midY)
%rotates coordinates around eighter a given origin, or the middle of the
%shape
if nargin < 4
%no origins given
%calculate the middle point of the shape
midX = mean(x);
midY = mean(y);
end
%transpose the middle of the shape to the ... |
function result = feature_extraction(data_path, windowing_size)
% data_path = '/Users/burakonal/Desktop/edu/58j/hw3/PIRC2017_03';
image_size = [128 128];
% windowing_size = [16 16];
class_names = cell(32,1);
names = dir(data_path);
j=1;
for ii=1:length(names)
if names(ii).name(1) == ... |
function [ weights, theta ] = getNetwork(X,nI,nH,nO)
weights = {};
dims = [nI,nH,nO];
for i = 1:length(dims)-1
tmp = dims(i)*dims(i+1);
weights{i} = vec2mat(X(1:tmp),dims(i));
X(1:tmp)=[];
end
theta = {};
dims = [nH,nO];
for i = 1:length(dims)
tmp = X(1:dims(i));
theta{i} = tmp(:);
X(1:dims(i)) = [];
end... |
% Check whether a graph is weighted, i.e not all edges are 0,1.
% INPUTS: edge list, m x 3, m: number of edges, [node 1, node 2, edge weight]
% OUTPUTS: Boolean variable, yes/no
% GB, Last updated: October 1, 2009
function S=isweighted(el)
S=true;
if numel( find(el(:,3)==1) ) == size(el,1); S=false; end |
function t = multihopMassSpring(t)
%t = massSpring(t)
%
%This function repeatedly applies forceResolution to all nodes. Note that
%forceResolution uses multi-hop distances
error(2) = 0;
error(1) = -1;
iter=0;
while error(2)-error(1) > .1
t = forceResolution(t);
error(2)=error(1);
error(1)=find... |
function obj = setMassMatrix(obj, Mlist)
% Set the mass matrix M(x) of the system
%
% Parameters:
% M: the mass matrix M(x) @type SymFunction
x = obj.States.x;
% validate and set the mass matrix M(x)
if ~iscell(Mlist), Mlist = {Mlist}; end
if ~isempty(Mlist)
... |
% calculate Keq for HO2 + NO2 -> HO2NO2
% Updated 7/18/06 AEP
% Based on JPL Data Evaluation #15
% rate=keqHO2NO2(T,M)
function j=keqHO2NO2(T,M)
j=2.1e-27.*exp(10900../T); |
clear all;% clc;
% close all;
Config();
% warning('off','all');
functPlot = @(x) abs(x);
Sys.pOrd = 4;
Sys.hOrd = 1;
prjName = 'CapSense';
scale = 1e-3;
Mesh = IOrPoly(prjName, 'q34aA', Sys.hOrd, scale);
% PlotMesh(Mesh,1);
% PlotPoly(prjName,figure);
Mesh.epsr = [1 10];
Mesh.BC.Dir = [1 2];
Sys.V{1} = 0;... |
%% Exercise 11.3
figure(1)
N=1000; m=pam(N,2,1); % random +/-1 signal of length N
M=20; mup=zeros(1,N*M); mup(1:M:N*M)=m; % oversampling by factor of M
ps=ones(1,M); % square pulse width M
x=filter(ps,1,mup); % convolve pulse shape with mup
neye=5;
c=floor(length(x... |
% Conver from quaternion to Rotation MAtrix
% form of quaternion must be [x y z w]' (horizontal or vertical vector)
function C = QuatToRotMat(q)
if length(q) ~=4
error('Quaternion has not the form [x y z w]');
return
end
crossprodmat = VectorToCrossMat(q(1:3));
C = eye(3) - 2*q(4)*crossprodmat ... |
fmed = im2uint8(medfilt2(f, [5 5]));
% fgauss=im2uint8(imgaussfilt(fmed,10));
I=fmed;
% Step 2: Use the Gradient Magnitude as the Segmentation Function
hy = fspecial('sobel');
hx = hy';
Iy = imfilter(double(I), hy, 'replicate');
Ix = imfilter(double(I), hx, 'replicate');
gradmag = sqrt(Ix.^2 + Iy.^2);
figure... |
function [currentState, logP] = hmmviterbi(self,data,opt_varargin)
n=0;
if isempty(opt_varargin)
program_option;
n=size(opt_varargin,2);
elseif isstruct(opt_varargin{1})
opt=opt_varargin{1};
else
program_option;
n=size(opt_varargin,2);
... |
clear
% load('sylvseq.mat');
load('carseq.mat'); % car data
[Vid_height,Vid_width,fram_num]=size(frames);
% rect=[102,62,156,108];
rect=[50,110,150,157]; % car data
rects=zeros(fram_num,4);
epsilon=4;% set the threshold of difference bewteen p and p_star
for i=1:fram_num-1
%% calculate the delta_p, same with KLT
... |
function [data, Xtrain, Ytrain, Xtest, Ytest, params] = initialize_parameters(dataset_type)
%INITIALIZE_PARAMETERS Initialize the parameters to train a GMM classifier on the given data
% input------------------------------------------------------------------
% o dataset_type: (string) The choosen dataset (twos... |
function [numopen, denopen, denclsd]=fbdesign(num,den,s1)
% Hadi Saadat 1998
clc
discr=[
' '
' The function fbdesign(num, den, s1) is used for the minor-loop feedback'
' design of a linear control system. num & den are row vectors of ... |
function [ll grad P V delta] = ml_3(beta, x, shares, choice, delta)
grad_sum = 0;
ll_sum = 0;
n = rows(x)/100;
index_start = 0;
delta = feval('delta3', beta, x, n, delta, shares);
for i = 1:n;
sum_i = 0;
sum_n = 0;
sum_j = 0;
index = index_start + 1;
z = x(index:index+99, 1:cols(x));
... |
classdef (HandleCompatible) FancyclipBase
% This class is a trick to support automatic library initialization
%
% To use it, have all your classes that depend on the library being
% initialized inherit from this.
properties (Constant, Hidden)
initializer = fancyclip.internal.LibraryInitializer;
end
... |
function compute_texture(dir_root,dir_masks,window)
if dir_root(end) ~= '/'
dir_root = [dir_root '/'];
end
if dir_masks(end) ~= '/'
dir_masks = [dir_masks '/'];
end
ext_mask = '_mask.tif';
ext_img = '.jpg';
files = dir(strcat(dir_root,'*',ext_img));
nFiles = length(files);
for i=1:nFiles
name = fi... |
function [rv]=nbody(dt,rvmg)
%r0_and_v0=[r0,v0]
l=(length(rvmg)-1)/7;
r0=rvmg(1:l*3); %r0=[m_i,x,y...z]
r10=rvmg(l*3+1:l*6); %v0=[m_i,dx/dt,dy/dt...dz/dt]
m=rvmg(l*6+1:l*7);
G=rvmg(end);
%r2=zeros(length(m),size(r0,2));
for i=1:l %object number
ii=3*[1:l]-3+i;
m_ni=m(1:end~=i); %masses other m_i
r_ni=r0; r_... |
classdef ActionType < uint8
%ACTIONTYPE Enumeration class used to represent the 6 possible
% human action types 'recognised' by this system.
enumeration
Boxing (1)
Handclapping (2)
Handwaving (3)
Jogging (4)
Running (5)
Walking (6)
end % enumeration
en... |
function varargout = angmean(varargin)
%ANGMEAN - Angular mean, vector strength, and standard deviation
% function [mean,R,stdev] = angmean(ang,dim)
% or = angmean(x,y,dim)
%
% second form is for unit vectors. dim is optional, which makes the two
% forms ambiguous (in the rare instance that numel(... |
function plotMedialCurves(medialCurves)
srepsEnums;
nCurves = length(medialCurves);
for i = 1:nCurves
curve = medialCurves(i);
controlPts = curve.controlPoints;
wts = curve.weights;
type = curve.type;
if (size(controlPts,1) == 2)
plot(controlPts(1:2,1),controlPts(1:2,2),'r:');
else
... |
function dispv(message, verbosity)
if verbosity>0
disp(message)
end |
close all; clear all; clc;
e=10.^(5:0.00001:10);
nui_air1=air1(e,0,10);
nui_morrow=morrowair(e,0,1);
nua_air1=air1(e,0,2);
nua_morrow=morrowair(e,0,2);
mue_air1 = air1(e,0,11);
mue_morrow = morrowair(e,0,4);
ve_air1 = -mue_air1.*e;
ve_morrow = -mue_morrow.*e;
alpha_i_air1 = nui_air1./abs(ve_air1);
alpha_a_air1 = nua_a... |
% WDCBM Birge-Massart法を使って、ウェーブレット1次元雑音除去または圧縮に
% 対応するスレッシュホールド
%
% [THR,NKEEP] = WDCBM(C,L,ALPHA,M) は、Birge-Massart 法を用いたウェーブレット
% 係数の選択規則によって得られる雑音除去、または圧縮に関して、レベルに
% 依存にするスレッシュホールド値 THRと係数の数を保持する NKEEP を出力します。
%
% [C,L] は、レベル J0 = length(L)-2 において雑音除去、または圧縮された信号の
% ウェーブレット分解構造です。ALPHA は、1より大きい実数でなければなりません。
... |
img1=imread('C:\Users\Lenovo\Desktop\da2.jpg');
img1=im2bw(img1);
%GetFOF img1 must be two-dimensional.
[pixelCounts, GLs] = imhist(img1);
NM = sum(pixelCounts); % number of pixels
% Calculate the mean
meanGL = sum(GLs .* (pixelCounts / NM));
varresult = 0; % variance temp var
skewr... |
addpath('quaternion_library'); clear all;close all;clc;
load('ExampleData.mat');
%Ideal Accelerometer Data----------------------------------------------------
N = 1000;rng(1);
acc = zeros(N,3);av = zeros(N,3);
q = randrot(N,1); % uniformly distributed random rotations
imu = imuSensor('accel-mag');%imu2 = imuSensor('ac... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.