text stringlengths 8 6.12M |
|---|
function CoMs = CoMfwkin(q1,q2,q3,q4,q5)
% angles in rad
l1 = 4.125 * 25.4; % mm
l2 = 6.43 * 25.4; % mm
link1_CoM = 50.56;
link2_CoM = 83.84;
link3_CoM = 83.84;
link4_CoM = 56.94;
T01 = fwkintrans(l1,q1,0,-pi/2);
T02 = T01 * fwkintrans(0,q2-pi/2,l2,0);
T03 = T02 * fwkintrans(0,q3,l2,0);
T04 = T03 * fwk... |
function [torqueVsSpeed,speed,torque] = torqueMapCalc(Powertrain,tyreRadius,efficiency)
% *************************************************************************
% FUNCTION NAME:
% torqueMapCalc
%
% DESCRIPTION:
% This function finds the Torque vs Speed map based on given parameters
%
% INPUTS:
% Power... |
function [] = autoassigndocfiles( Dr, outputDir )
%AUTOASSIGNDOCFILES Autogenerates and assigns filenames for the output documentation
%
% [] = Dr.autoassigndocfiles( )
% [] = Dr.autoassigndocfiles( outputDir )
%
% Sets the `docFile` property.
%
% If `Dr` is a Documentor object array, `autoassigndocfiles... |
function ime = CS4640_RLE_encode(im)
% CS4640_RLE_encode - produce run-length encoding of gray level image
% On input:
% im (MxN array): gray level image
% On output:
% ime (1x2k vector): k run length encodings; odd-numbered give run
% length, while even numbered give gray level
% Call:
% ime = CS46... |
clear;
close all;
clc;
Ta = 0.2;
t = [0:Ta:5]';
x = sin(2*pi*t);
figure(21);
ReconstroiSinal(x, Ta);
Ta = 0.04;
t = [0:Ta:5]';
y = sin(10*pi*t) + cos(12*pi*t) + cos(14*pi*t-pi/4);
figure(22);
ReconstroiSinal(y, Ta);
Ta = 0.1;
t = [-5:Ta:5-Ta]';
z = sinc(5*t);
figure(23);
ReconstroiSinal(z,Ta); |
function [t,H,q,p] = EmbeddedRK45(fcn, tspan, q0,p0, n)
% classical fourth order method
% Solve the initial value problem
% y’ = fcn(t,y), t0 <= t <= b, y(t0)=y0
M = 0.9953;
S = 1.814;
D = 90.5*0.4814E-3;
t0 = tspan(1);
t_end = tspan(2);
h = (t_end-t0)/n; % step size.
t = t0:h:t_end;
disp(t)
H = zeros(1... |
function [label] = classif(img)
%CLASSIF Summary of this function goes here
% Detailed explanation goes here
load('categoryClassifier.mat');
[labelIdx, scores] = predict(categoryClassifier, img);
% Display the string label
label = categoryClassifier.Labels(labelIdx);
end
|
%% AMM MASTER SCRIPT
% This script will process the data for the auditory motion metaphor study
%
% Written by Anja Jamrozik and Andrew S Bock Aug 2016
%% Set up initial variables
dataDir = '/data/jag/ajamrozik/Data/AMMet/';
subjDirs = listdir(dataDir,'dirs');
SUBJECTS_DIR = getenv('SUBJECTS_DIR');
shellScriptDir = '... |
function [data, seq] = fastaread(filename,varargin)
%FASTAREAD reads FASTA format file.
%
% S = FASTAREAD(FILENAME) reads a FASTA format file FILENAME, returning
% the data in the file as a structure. FILENAME can also be a URL or
% MATLAB character array that contains the text of a FASTA format file.
% S... |
%%
% Implements the incremental learning rule for linear neurons
%%
% First create a linear relationship with randomly generated
% predictor variables x, coefficients b and effect variable y
x = unifrnd(0,10,10,4)
b = [1 -2 3 -4]'
y = x*b
% The truth is hard to know, so let's introduce some normally
% distributed no... |
function [A,comm] = direct_load_lfr(net,lab)
% net: network.dat adjacency matrix
% lab: community.dat labels for communities
% A: Adjacency matrix
% comm: community matrix. comm(i,j) = 1 if node i belongs to comm j
network = load(net);
n = max(network(:));
if size(network,2) == 2 % unweighted
A = sparse(network(... |
function Ei800_uvw100_at1m10auto(varargin)
data_source= fullfile(pwd,'Data','Fe_ei787.sqw');
avrg_par=[0,0,1139.482];
no_chkpnts='True';
pause on
Imax = 0.2;
if nargin == 0
repPoints1=[-0.275,-0.225,0,0.275,0.425;
117,42,0,60,225];
repPoints2 = [-0.325,-0.225,0,0.275,0.325;
... |
clc
close all
clear all;
u=imread('Cloud.png');
s=size(u);
display(s);
I=rgb2gray(u);
for i=1:1:20
for j=1:1:20
if(I(i,j)>200)
I(i,j)=1;
end
end
end
I=flip(I,1);
display(I);
global a;
a = arduino();
global elbow shoulder wrist;
elbow=servo(a,7,'MinPulseDuration... |
function xout = remmean(xin, dim)
% xout = REMMEAN(xin, dim)
%
% inputs
% - xin: a double array (1D, 2D, N-D).
% - dim: dimension along which to calculate the mean.
%
% outputs
% - xout: double array the same size as xin.
%
% REMMEAN.m is a simple function to remove the mean
% of xin along the dim... |
function [V, policy, cpu_time, VA, VB, VC, VD, VE, VSL] = mdp_finite_seghorizon_SLABCDEb(opt,NX, NY, MAXD, K, r, c, h, s, discount, N, hv)
cpu_time = cputime;
global mdp_VERBOSE;
if ~exist('mdp_VERBOSE'); mdp_VERBOSE=0; end;
% check of arguments
if N < 1
disp('---------------------------------------------------... |
clear all
pit = load('Precompute/Controls_n=20_numThe=80_gps=5');
A = pit.A;
n = pit.n;
[num_goal_pts,~] = size(pit.goal_configs);
num_theta = 80;
dt = 2*pi/num_theta;
theta_vec = -pi+dt:dt:pi;
cnt = 1;
for th1 = 1:80
for th2 = 1:80
for gps = 1:8
for dir = 1:2
temp = A{th1, th... |
clear;
load AR_part.mat;
for t=0:6
X_trn1=cell(100,1);
X_tst1=cell(600,1);
X_trn2=cell(100,1);
X_tst2=cell(600,1);
Y_trn1=zeros(100,1);
Y_tst1=zeros(600,1);
Y_trn2=zeros(100,1);
Y_tst2=zeros(600,1);
count1=1;
count2=1;
for i=1:700
if(rem(i,7)==t)
X_trn1{count1}=equalization(floor(imresize(X1{i},[120,90])));... |
function energy_demo()
[musica ,voz] = concatena();
alfa = 0.9;
Ex= sum( voz.^2 );
Ey= sum( musica.^2 );
fprintf("Ex = %d \n", Ex);
fprintf("Ey = %d \n", Ey);
Ez_sum = (alfa^2 * Ex) + ((1-alfa)^2 * Ey);
fprintf("A soma de Ex e Ez com fator alfa é %d \n",Ez_sum);
dim = length(musica)- length(voz);
x_n=zeros(1,dim)... |
for clusterNum = 2:1000
a.newClust{clusterNum} = stepWiseClusters(:,clusterNum) - stepWiseClusters(:,clusterNum-1);
a.newClustInd{clusterNum} = find(a.newClust{clusterNum} ~=0);
a.OldClustNum(clusterNum) = stepWiseClusters(a.newClustInd{clusterNum}(1),(clusterNum-1));
a.NewClustNum(clusterNum) = st... |
%making plot at t=0.1
Ur1x = zeros(nx);
Ur2x = zeros(nx);
Ur3x = zeros(nx);
Ur0x = zeros(nx);
for i=1:1:20
Ur1x(i)=Ur1(15,i);
Ur2x(i)=Ur2(15,i);
Ur3x(i)=Ur3(15,i);
Ur0x(i)=Ur0(15,i);
end
plot(x,Ur1x,'r:',x,Ur2x,'g:',x,Ur3x,'b:',x,Ur0x,'k');
title('exponential function')
xlabel('Distance x (at t = 0.75)'... |
function newSpectra=deleteIsoPeaks(varargin)
%
% Deletes isotopic peaks from input SpectraA and returns newSpectra
%
% Children Function: findIsotopePeaks
%
if (nargin==3)
SpectraA = varargin{1};
MS2tol= varargin{2};
MS2tolUnit= varargin{3};
else % lines for debugging program
mzDTA = readmzDTA('C:\gl... |
function prog(script_name)
%PROG Runs a script with progress bars
%If a script has been correctly annotated and calls 'prog' initially,
%then prog will automatically generate a temporary file with boilerplate
%code for progress bars, run this code in the base workspace, and delete
%the temporary file. The ini... |
function target_features = get_target_features(session_instance)
% GET_TARGET_FEATURES - Target sound features accessor.
%
% Usage: target_features = get_target_features(session_instance)
%
target_features = get_features(session_instance.target);
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Author: Hamza Bourbouh <hamza.bourbouh@nasa.gov>
% Notices:
%
% Copyright @ 2020 United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration. All
% Rights Reserved.
%
% Disclaimers
%
% No Warranty:... |
%@(#) hrot2qrot.m 1.1 06/09/13 15:09:41
%
%function hrot2qrot(distfil_in,distfil_ut);
function hrot2qrot(distfil_in,distfil_ut);
dist_str=['ASYID ';'ASYTYP '];
dist_2d= ['EFPH ';'KHOT '];
dist_3d= ['BURNUP '];
[khot,mminj]=readdist7(distfil_in,'khot');
burnup=readdist7(distfil_in,'burnup');
i=find(mean... |
function x = make_start_x(prob)
% Compute a truncated SVD for starting guess.
lan_options.tol = 1e-3;
M_omega = sparse(prob.Omega_i, prob.Omega_j, ...
prob.data,prob.n1,prob.n2,prob.m);
[U,S,V] = lansvd(M_omega, prob.r,lan_options);
x.V = V;
x.sigma = diag(S);
x.U = U;
x = prepx(prob, x);
|
function [codew, pulsew, prt, fs] = readTxParameters(echoWaveTables)
% 单位转换, 凡是遇到时间都将us都转换为s, 凡是关于频率都加上Mhz单位
us2s = 1e-6;
toMhz = 1e6;
% 读码宽、脉宽、prt、fs
codew = echoWaveTables(1, "CodeWidth").CodeWidth * us2s;
pulsew = echoWaveTables(1, "PulseWidth").PulseWidth * us2s;
prt = echoWaveTables(1, "PRT").PRT * us2s;
fs = ech... |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% Set the Parameters of the Problem to Optimize %
% and %
% ... |
#Ejercicio 3
#Simulacioncita de un tanquecito de volumen constante con sustrato entrando
#Condicion inicial
Vol = 1
Co = 0; # En molar
Cin = 1; # En molar
F = 0.5; # En litros por hora
#Rango de tiempo para resolver la ecuacion
tiempo =(0:0.1:30)';
#Defino la ecuacion diferencial
function dC = fder (cc,tt) #En mat... |
function [ymean, yvar, model] = ibpmultigpPosterior(model, Xtest)
ymean = cell(1, model.nout);
yvar = cell(1, model.nout);
fhandle = str2func([model.kernType 'KernCompute']);
if isfield(model, 'gamma') && ~isempty(model.gamma)
[Kff, Kfu, ~] = fhandle(model.kern, Xtest, model.latX, model.gamma);
else
[Kff, Kfu... |
function [] = plotLSE(X, y, fig)
figure(fig);
[w b] = LSE(X, y);
plotClasses(X, y);
plotDecisionSurface(fig, X, b, w, 1);
end
|
function Options = rlACAgentOptions(varargin)
% rlACAgentOptions: Creates options for AC Agent.
%
% OPT = rlACAgentOptions returns the default options for rlACAgent.
%
% OPT = rlACAgentOptions('Option1',Value1,'Option2',Value2,...) uses name/value
% pairs to override the default values for 'Option1','Option2',..... |
function wbar = guiStartWaitBar(value, text)
% wbar = guiStartWaitBar(value, text)
% Shows progress bar.
%wbar = 0;
wbar = waitbar(value, text);
|
function [ G,time ] = Graph_G_T2( n )
%GRAPH_GENERATOR generates a graph
% G is undirected := symetric matrix
time=0;
G = zeros(n);
SG=sparse(G);
v=graphtraverse(SG,1,'Directed','false','Method','BFS');
while length(v)~=n
i=ceil(rand()*n);
j=ceil(rand()*n);
while(G(i,j) ~= 0 || i==j)
i=ceil(r... |
function [ dtheta ] = eqns1( t, theta, Io, m,g, R, alpha, b, c, P0, kp, ag, omega, phi, Tex, thetay)
dtheta=zeros(2,1);
ddu=ag*sin(omega*t+phi)*heaviside(Tex-t); % y=heaviside(x) if x<0, y=0; if x>0,y=1.
term1=m*g*R*sin(alpha*sign(theta(1))-theta(1));
term2=c*theta(2)*(2*b*cos(theta(1)/2))^2;
% term2=c*sign(theta(2... |
% Normalized n-dimensional cross-correlation with a mask.
%
% Similar to normxcorrn, except takes an additional argument that specifies
% a figure ground mask for the T. That is T_fg must be of the same
% dimensions as T, with each entry being 0 or 1, where zero specifies
% regions to ignore (the ground) and 1 specifi... |
% RPCL, rival penalized competitive learning,改进版的Kmeans
% 根据http://www.cs.hmc.edu/~asampson/ap/ap.git移植而来
clear;
close all;
iter = 30; % 最多迭代次数
%load 'stimuli.txt';
%data = stimuli; clear stimuli;
load 'dita.txt';
data=dita; clear dita;
sample_num = size(data, 1);
sample_dimension = size(data, 2);
le... |
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
clc;clear;close all;format shortg
addpath([pwd,'/utility/'])
addpath([pwd,'/utility/effectsize/'])
load('twistedxor2data.mat')
whos
% Name Size ... |
%after adding new features in the features set add n in the features and getvocablist files
% Load Vocabulary
vocabList = getVocabList();
[vocabList1 vocabList2]=getabbre();
bi=getBi();
tri=getTri();
%-----------------------------------------------------------------------------------------
X=[];
fid = fopen('t... |
function [inputX,data] = simulateData(modelProblem,nReactions,nSpecies)
rng(1,'twister');
rng(1,'twister');
tic
if modelProblem==2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Model Problem 2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dataStdDev=2.0;
nData=30;
tim... |
function display_img1_on_img2(img_background, img_foreground, thershold)
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
% imR= img_foreground(:,:,1); imG= img_foreground(:,:,2); imB= img_foreground(:,:,3);
% ind = imB>200;
% imR(ind) = 255; imB(ind) = 255; imG(ind) = 255;
%
% im_tr... |
% DESCRIBEMODELCOMPARISONMETHOD Describe in words the various model comparsion metrics
%
% DescribeModelComparisonMethod(name);
%
% Given the name of a model comparison metric (e.g., 'AIC'), prints a
% description of its meaning.
%
function DescribeModelComparisonMethod(name)
switch name
case 'AIC'
st... |
function [G]=dist2gram(D)
n=size(D,1);
v1=ones(n,1);
D=D.*D;
J=eye(n)-(1/n)*(v1*v1');
G=-0.5*(J*D*J);
|
%% use diff function to generate spatial Jacobian
dq1 = diff(g_st,q1);
x1 = rbvel2twist(dq1*inv(g_st));
dq2 = diff(g_st,q2);
x2 = rbvel2twist(dq2*inv(g_st));
dq3 = diff(g_st,q3);
x3 = rbvel2twist(dq3*inv(g_st));
dq4 = diff(g_st,q4);
x4 = rbvel2twist(dq4*inv(g_st));
dq5 = diff(g_st,q5);
x5 = rbvel2twist(dq5*inv(g_st));... |
function [exp_clean,unitnames,snrs] = struct_clean(exp)
% OBJECTIVE:
% clean up struct to not include empty trials or bad units, and reorder unit names to consistent across trials
%
% INPUTS:
% exp = where data in rows of exp.dataMaestroPlx are individual trials
%
% OUTPUTS:
% exp_clean = new exp including trials w/ sp... |
paths = ['common:', genpath('libs'), genpath('SSSC')];
addpath(paths);
run('vlfeat/toolbox/vl_setup');
if exist('matlabpool','file') && matlabpool('size') == 0
matlabpool open
end
rng(1)
load('data/TIRlib');
n_runs = 50;
n_cluster = 5;
cluster_size = 20;
n_steps = 10;
max_noise = 0.4;
n_spectra = 5;
missrate... |
for i = 1:laps
Rload = toleranz_data.load.values(i);
L = toleranz_data.inductor.values(i);
T = 1/toleranz_data.frequency.values(i);
fprintf('Start simulation run %i of %i laps ',i,laps);
sim('Buck_Converter');
I = simlog.real_Buck.Load.i.series.values;
U = simlog.real_Buck.Load.v.seri... |
% function [vk,rck,hk,zk,sik,OCV] = simCell(ik,T,deltaT,model,z0,iR0,h0)
% ik - current, where (+) is discharge
% T - temperature (degC)
% deltaT = sampling interval in data (s)
% model - standard model structure
% z0 - initial SOC
% iR0 - initial resistor currents as column vector
% h0 - initial hysteresis state
fun... |
% True solution
x = 0:0.1:1;
e = exp(1);
y1 = x - (8*sin(pi*x))/(pi^3*(pi^2 + 1));%n = 2
y2 = x - (8*sin(pi*x))/(pi^3*(pi^2 + 1)) - (8*sin(3*pi*x))/(27*pi^3*(9*pi^2 + 1));%n = 3
y = (2*e-2*e^2)/(e^2-1)*exp(-x)+(2-2*e)/(e^2-1)*exp(x) + x.^2+2;
plot(x,y1,'--o',x,y2,'-.D',x,y,'-*')
legend('n=2拟合结果','n=3拟合结果','真解'); |
%% HRTF
clc, clear all, close all
azi=276;
eleArr=[-40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90];
eleInd=9;
eleFil=['elev' int2str(eleArr(eleInd))]
radii=4;
fileL='';
fileR='';
cd 'C:\Users\Laste\Documents\MATLAB'
disp('Directory changed')
while ((exist(fileL,'file') ~= 2) && (exist(fileR,'file') ~= 2))
... |
function RHSdiv = divergenceTerm1D(F)
% This function calculates the divergence of a field using its face
% average value
%
% SYNOPSIS:
% RHSdiv = divergenceTerm1D(F)
%
% PARAMETERS:
% F: Face Variable
%
% RETURNS:
%
%
% EXAMPLE:
%
% SEE ALSO:
%
% extract data from the mesh structure
Nx = F.domain.dims(1);
G = 1:... |
function [frame] = function_UndoLF(calib, LF)
LF = permute(LF,[5 4 3 2 1]);
[LX,LY,LKX,LKY,LT] = size(LF);
if LT == 1
disp(strcat('Back-converting --1-- frame'))
frame = zeros(calib.FrameLX,calib.FrameLY);
for i = 1: calib.FrameLX
for j = 1: calib.FrameLY
if min(calib.matrice(i,j,:))>0... |
function [check] = check_delta(G,eps, eps_d, delta, n, W)
% G:Window Function,
G_ft = fft(G);
ABS_G_ft = abs(G_ft);
n_eps = ceil(n*eps);
n_eps_d = floor(n*eps_d);
l = numel(G);
G_eps = ABS_G_ft(n_eps:l-n_eps+1);
G_eps_d = [G_ft(1:n_eps_d);G_ft(l-n_eps_d+1:l)];
C_esp = (G_eps >= delta);
C_esp_d = (G_eps_d < 1-delta ... |
function Out = prepareVisu(this)
Out = zeros(this.visuHeight, this.visuWidth, 3);
for i = 1:numel(this.stacks)
switch (this.stacks(i).mode)
case 'xy'
% Prepare visualization
tmp = rescaleHist(this.stacks(i).data(1:this.zoom:end, 1:this.zoom:end));
for c = ... |
clear
clc
tic
q = imread("T2.png")-186 ;
x_total = sum(q,1)>0;
y_total = (sum(q,2)>0).';
distance = 1;
TDD = 2*distance*tan((100*pi)/360);
D_Ratio = TDD/100;
Pattern = [0 1] ;
Pattern_1 = [1 0] ;
Xinitial = strfind(x_total , Pattern) + 0.5 ;
Xfinal = strfind(x_total , Pattern_1) + 0.5 ;
X = Xini... |
% Example:
%
% Aritmetic: Subtraction for detection
%
% Computer Vision Course
% (c) Domingo Mery (2014) - http://dmery.ing.puc.cl
close all
i1 = 20;i2 = i1+100;
j1 = 340;j2 = j1+150;
A = imread('sub1.bmp');
A = imresize(A(i1:i2,j1:j2),[512 512]);
figure(1);
imshow(A,[]);
title('Image A');
enterpause
B = imread('sub2... |
function [Aeq, beq]= getAbeq(n_seg, n_order, waypoints, ts, start_cond, end_cond)
n_all_poly = n_seg*(n_order+1);
%#####################################################
% p,v,a,j constraint in start,
Aeq_start = zeros(4, n_all_poly);
beq_start = zeros(4, 1);
% expression of Aeq_start and ... |
function seslist = hasmatlabData(datafolder,varargin)
%Use as seslist = hasmatlabData(datafolder) or hasmatlabData(datafolder, do) . Checks wether the
%matlabData.mat file exist for all experimantal folders in 'datafolder'.
%Can be either in the main folder or in a folder called ' Sort'. If do ==
%true (default) re... |
function extract_cnn_patches(video_names,param)
% create cache folders
cdirs={'patches_app','patches_flow','patches_app/left_hand','patches_flow/left_hand', ...
'patches_app/right_hand','patches_flow/right_hand','patches_app/upper_body','patches_flow/upper_body', ...
'patches_app/full_body','patches_flow/full_... |
function betas = fn_mass_GLM(X,y,add_offset)
%function betas = massGLM(X,y,add_offset)
%efficiently calculates betas for mass univariate GLM
%
%inputs: X (design matrix) should be nTrials*nRegressors
% y (data) should be nTrials*nChannels*nTimepoints(*nFrequencies)
% add_offset should be true to add a con... |
function result = generate_topology (topology_name, num, den)
% generate_topology: Topology charge and voltage multiplier generation
%
% result = generate_topology (topology_name, num [, den])
% topology_name: Name of SC topology {Ladder, Dickson, Cockcroft-Walton,
% Doubler, Series-Parallel, Fibonacc... |
function [collapsePartitionData] = analyze_periodicity(rotations,correlations)
% Partitions the sinusoidal correlation data into n even partitions. Collapses the
% partitions by calculating the summation of all n partitions. Data is used
% for periodicity analysis.
rotations = rotations(1:60);
correlations = correlati... |
function yy = naturalspline(x, y, xx)
%lungimea lui x
n = length(x);
%initializare vectori de lungime n - 1
h = zeros(1, n - 1);
b = zeros(1, n - 1);
%in h retin diferenta elementelor din x, iar in b derivatele in fiecare punct din h
for i = 1 : n - 1
h(i) = x(i + 1) - x(i);
b(i) = (y(i + 1) - y(... |
function [maximum,index,ncorr] = norm_corr(A,B,gap)
% Normalized Correlation
tar = target_im(A,B,0.0625);
tar = (tar-min(tar(:)))/(max(tar(:))-min(tar(:)));
ncorr = [];
for i=-0.5:gap:0.5
disp(i)
test = target_im(1,0,i);
test = (test-min(test(:)))/(max(test(:))-min(test(:)));
ncorr_temp = max(max(nor... |
function d2fdxdpval = loggenlin_d2fdxdp(t,x,p,more)
% LOGGENLIN_D2FDXDP computes second partial derivatives of values of fits
% to logged observations at time t with respect to state values in Y and
% parameter values in P
% Observations are related to variable values x by the equation
% Fit = xA' + fB' where x i... |
function Options = rlSARSAAgentOptions(varargin)
% rlSARSAAgentOptions: Creates options for SARSA Learning Agent.
%
% OPT = rlSARSAAgentOptions returns the default options for rlQAgent.
%
% OPT = rlSARSAAgentOptions('Option1',Value1,'Option2',Value2,...) uses name/value
% pairs to override the default values for... |
function Sim16
%% Reset
close all
clear
%% Load data
load('Groups4.mat');
%% Set names
simName = '16 Groups of 4, narrow, 5 min delay';
folderName = 'Sim16';
%% Set conditions
[Sim.Luminaires.View] = deal('narrow');
[Sim.Zones.DimAfter] = deal(duration(0,5,0));
[Sim.Zones.OffAfter] = deal(duration(0,5,0));
[Sim, t... |
function [ ] = f_save2pdf( from, to, cols )
%PLOTALL Plot all functions from f_{from} to f_{to}
%
if nargin < 3
cols = 5;
end
if nargin < 2
to = 24;
end
if nargin < 1
from = 15;
end
num = to - from + 1;
rows = ceil(num / cols);
for I = 1:num
no = I + from - 1;
try
figure;
f... |
%% Chargement des resultats %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
output = 'output';
data = load([output '_T.out']);
N = sqrt(length(data));
Y = data(1:N,2);
X = data(1:N:N*N,1);
T = reshape(data(:,3),N,N)'; % 1D -> 2D
h = (max(X)-min(X))/(N-1);
data = load([output '_P.out']);
t = data(:,1);
Pc = data(:,2);
Pf ... |
function x = turbo_enc(msg,trellis,m)
[x,final_state] = convenc(msg,trellis);
tail=x(end-1:end);
% forcing the RSCC to the zero state
% mask is the feedback path connections
mask = de2bi(oct2dec(13),m); mask = mask(1:end-1);
for ii=1:(m-1)
% trellis state in binary
bstate = de2bi(final_state,m-1);
% xor'd ... |
function y = int_ispow(x)
% (v & (v - 1)) == 0;
y = bitand(x,x-1)==0;
|
function [result,overallInfected,overallFatality,data]=computeFinalSize_generalized(vacDistParm,adultAges,IFR,w,R0,C,N,r,v,infected0_v,infected0_nv,nuVac,betaVac,effVac,overallInfected_uniform,overallFatality_uniform)
vacDist=0*r;vacDist(adultAges)=vacDistParm;
infected=infected0_nv+infected0_v;
v_protected=nuVac*(v+... |
function h=h_given_TVN(x)
% Calculates spesific entalphy from given temperature, volume and
% mole number. Input x=[T;V;N]
% Downloaded from the personal page of Professor Sigurd Skogestad
% http://www.nt.ntnu.no/users/skoge/diplom/prosjekt03/wold/MatLab/
A = co2_sw(x);
h = [x(1),x(3)]*[-A.g(1);A.g(3)]/x(3);
|
function inputs = readInputs(file)
fileID = fopen(file,'r');
inputs = struct;
if exist(file, 'file') == 2
%fprintf(['Loading', file, '\n']);
file_contents = fileread(file);
else
return;
end
% Parse file_contents
regex = '\.(.[^\n\.]*)=(.[^\n]*)[\n]';
[~,matches,~] = regexp(file_contents, regex, 'match... |
function fscanftest3
fd = fopen('danefscanf.txt','r');
[A,liczba]=fscanf(fd,'%5c%*f%9c%*f%*5c',[2 inf])';
A
fclose(fd);
return
|
function ta = lookUpTacticalActionCode(tac)
grA1=floor(tac/10);
grA2=mod(tac,10);
ta=[grA1;grA2];
end |
ff=0.001;
fb=0.00001;
global pulse3IVM
global g1 g2 H2 L51 L52 L53 L54 L61 L62 L63 L64 L21 L22 L23 L24 L31 L32 L33 L34 L41 L42 L43 L44 k7 k9 k11 k13 k17 k19 k15 k21 k23 L11 L12 L13 L14 k2 k4 k6 k1 k3 k5 k8 k10 k12 k14 k16 k18 k20 k22 k24 E1 E2 alpha1 alpha2 alpha3 beta1 beta2 beta3 H11 H12 H13 H14 ks1 ks2 ks3 ks4 kd1 ... |
% Main code to generate transition candidate.
%this calls functions predictor.m and transition.m
%Stephen Walker 2009(stephen.walker@student.uts.edu.au)
%predictor.m determines the characteristics of an ellipse to model the trajectory based on the
%velocity and angle (with respect to the ellipse focus - the sun... |
% LDA Classification
clear
close all
clc
% Load supervised data and its feature vectors
load('SDSS.mat')
u_g =SDSStrain(:,1);%ultravoilet and green
g_r=SDSStrain(:,2);% green and red
r_i=SDSStrain(:,3);%read and infrared
i_z=SDSStrain(:,4);%infrared and near infrared
class=SDSStrain(:,5);%class 1- quasar 2-red gaint... |
%% Conversion of grades
clear all; close all; clc;
convertGrade(13,'13-scale')
convertGrade(12,'13-scale')
convertGrade(12,'7-point')
convertGrade(11,'7-point')
convertGrade(11,'8-point')
%% When to hire an employee
clear all; close all; clc;
hireApplicant(8,7)
hireApplicant(8,9)
%% Average hearing loss
clear all; clos... |
function w = fisherLDA(X, y)
% Find the optimal vector w to separate two classes
% X is n*d
% Y(i) = 1 or 2 is the label of case i
if length(unique(y))>2
error('can only handle binary data')
end
ndx1 = find(y==1);
ndx2 = find(y==2);
m1 = mean(X(ndx1,:))';
m2 = mean(X(ndx2,:))';
S1 = cov(X(ndx1,:));
S2 = cov(X(ndx2,:... |
%% DAMPER/SPRING COEFFICENT IN MOTORS
LegSpring=50000;
LegDamp=1000;
%% LOAD EXTERNAL FORCE/TORQUE
load('Suran_23rd.mat');
%%%%
xForce=matlabStruct_Data.interface_r_on_socket_r_in_ground_fx;
zForce=(-1)*(matlabStruct_Data.interface_r_on_socket_r_in_ground_fy);
yForce=matlabStruct_Data.interface_r_on_socket_r_... |
% set figure properties
kinem_figProps.m = 1;
kinem_figProps.n = 4;
kinem_figProps.panelWidth = ones(kinem_figProps.n,1) * 11;
kinem_figProps.panelHeight = ones(kinem_figProps.m,1) * 9;
kinem_figProps.colSpacing = ones(kinem_figProps.n-1,1) * 0.8;
kinem_figProps.rowSpacing = ones(kinem_figProps.m-1,1) * 1;
kinem_fig... |
function [B, totSig, R, pCha, vari, Alpha] = frugFunNoise(data, hazExp, noise, drift, likeWeight, learnNoise, C, trueRun, initGuess)
%input comes from fmincon (initially start_point)
% data is the values to estimate, hazExp is the expected hazard rate, noise is the expected standard deviation of the
% distribution, d... |
function handles = showCropLabels(handles)
%SHOWCROPLABELS Display labels of nerve, bone crops in main axis.
%
% See also: IDENTIFYIMAGEREFERENCES, COMPUTE2DNERVEKINEMATICS.
%==========================================================================
% Delete old objects. Note: there's gotta be a way to avoid deletin... |
%%原始蚁周系统的蚁群算法
%%清空环境变量
clear all; %清除所有变量
close all; %清图
clc ; %清屏
%%初始化参数----------------------------------------------------------
m=50; %% m 蚂蚁个数
Alpha=1; %% Alpha 信息素重要程度因子
Beta=5; %% Beta 启发函数重要程度因子
Rho=0.1; %% Rho 信息素挥发系数
NC_max=200; %%最大迭代次数
Q=100; %%蚂蚁循环一次释放的信息素总量
Coordinate=[
1... |
% http://archive.ics.uci.edu/ml/datasets/Adult
function [X, Y, K_classes] = get_adult_data()
if exist('datasets/adult.mat')
load('datasets/adult');
X = adultX;
Y = adultY;
K_classes = 2;
return;
end
adult_tr_data_fid = fopen('datasets/adult_tr.data');
t = textsc... |
function y = ierfc (x)
%ERF Error function.
% Y = IERFC(X) is the integral error function for each element of X.
% X must be real. The integral error function is defined as:
%
% ierfc(x) = exp(-x*x)/sqrt(pi) - x*erfc(x)
%
% Class support for input X:
% float: double, single
%
% See also ERF... |
function [sv, others] = sv_ecef(ephemeris, tr, ts0)
% 给定接收信号的时间和名义上信号发射的时间,计算在接收信号时刻地心固连坐标系下,卫星在发射信号时的坐标和信号路径长度
% 接收信号的时间需要是准确的GPS时间,需要将本地钟的钟差修正,剩余误差是本地钟的抖动
% 名义上信号发射的时间是接收到的C/A码理论上的发射时间,由于卫星钟的误差,需要补偿才能得到信号实际的发射时间,误差源是码环的跟踪误差
% 接收到的时间减信号实际的发射时间为信号的传播时间,用来对卫星位置进行坐标变换
% 传播时间并不等于路径长度,需要减去对流层、电离层、相对论效应的影响
% 因为校正电离层延迟需要位置信息... |
function [ PreCalc ] = meanStd(A, colDtt)
for classWalk=1:size(A,1)
PreCalc{classWalk,1} = mean(A{classWalk,1}(:,1:colDtt-1));
PreCalc{classWalk,2} = std(A{classWalk,1}(:,1:colDtt-1));
end
end
|
function [color_mat,idpos_mat,stim_mat,curv_vec,defsum_vec,time_vec] = Tail_load(tar_path)
%% Load the target file
%format the path from the parent
tar_file = strcat(tar_path,'.tdms');
%read the tdms file
[ConvertedData,~,ChanNames,~,~] = convertTDMS(0,tar_file);
%% Put the data on a cell array for easier access
%get ... |
close all;
clear;
clc;
img = imread('rail.jpeg');
ref = imread('child1.jpg');
r = size(img,1);
c = size(img,2);
he = uint8(zeros(r,c)); %histogram equalisation he final output
pixels = r*c;
f = zeros(256,1);
pdf = zeros(256,1);
cdf = zeros(256,1);
cum = zeros(256,1);
out = zeros(256,1);
for i=1:r
for j=1:c
... |
clc
clear all;
close all;
%Read image
im = imread('Connected.bmp');
figure(1);
imshow(im,[]); %Display Text.bmp
title('Input image');
[m,n] = size(im);
%Thresholding
thresh = 50;
im_neg = zeros(m,n);
for i = 1:m
for j = 1:n
if im(i,j)>thresh
im_neg(i,j) = 0;
else
im_neg(i,... |
function change_parameters()
global eta T timestamps
coords = inputdlg({'\eta [N*s/m^2]','T [K]', 'End time [s]', 'Time resolution'}, 'Parameters' , 1, {num2str(eta),num2str(T), num2str(timestamps(end)), num2str(length(timestamps))});
eta = str2double(coords(1));
T = str2double(coords(2));
t_end = str... |
function residueToTerminalChar = getresiduetoterminal(obj,residue,varargin)
%getresiduetoterminal return the string starting from specificied
% residue to the terminal
% getresiduetoterminal(obj,residue)
%
% See also removeNonRedEndResidue
if(~isempty(varargin))
nreResidue = varargin{1};
end
iterresidue = r... |
% This is material illustrating the methods from the book
% Financial Modelling - Theory, Implementation and Practice with Matlab
% source
% Wiley Finance Series
% ISBN 978-0-470-74489-5
%
% Date: 02.05.2012
%
% Authors: Joerg Kienitz
% Daniel Wetterau
%
% Please send comments, suggestions, bugs,... |
function fh = figureExpSuppressionLevel(dataCombineStructCells,varargin)
%绘制实验数据的压力脉动和抑制率图,这里的脉动抑制率是读取时自动和无内件缓冲罐的脉动抑制率,如果要自己计算
%请使用figureExpPressurePlusSuppressionRate
%允许特殊的把地一个varargin作为legend
pp = varargin;
errorType = 'ci';%绘制误差带的模式,std:mean+-sd,ci为95%置信区间,minmax为最大最小
rang = 1:13;
expVesselRang = constExpVesselRang... |
function MM = computeMM_separately(a)
N_mod = length(a);
alpha = {};
for j = 1:N_mod
alpha{j} = a(j);
end
M = computeMxyga(alpha{:});
R = computeR(alpha{:});
MM=zeros(N_mod,N_mod);
Mmod = zeros(N_mod,N_mod,N_mod);
for i = 1:N_mod
Mmod(:,:,i)=transpose(R(:,:... |
function [p_x] = pick_receptor(i,res)
p_x = res.receptor{i};
|
function atclearmex(rootdir)
%ATCLEARMEX Remove all AT mex-files
% Detailed explanation goes here
% <a href="matlab:web('https://atcollab.github.io/at')">AT Web site</a>.
% For more information, see <a href="matlab:
% doc('atmat')">atmat</a>.
% For more information, see <a href="matlab:
% help('atmat')">atmat</a>.
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.