text stringlengths 8 6.12M |
|---|
%MÉTODO EXPLÍCITO DE ADAMS-BASHFORTH DE CINCO PASOS
% - Introduzca la ecuación diferencial : 'Dy=y-(x^2)+1'
% - Introduzca la condición y(a)=b : 'y(0)=0.5'
% - Introduzca la función de trabajo : y-(x^2)+1
% - Introduzca el valor de a : 0
% - Introduzca el valor de b ... |
function [max_p, label_1] = find_max_P_2(dis_range,angle_range,x1,y1,x2,y2,x,y)
max_p = -20;
label_1 = 0;
for i = 1:length(x)
theta = calculate_theta_1(x1,x2,x(i),y1,y2,y(i));
dis = sqrt((x2-x(i))^2 + (y2-y(i))^2);
P = calculate_P(dis_range, angle_range, dis, theta);
if P > max_p
max_p = P;
... |
%% prt_patterns
% generates plots for patterns for display on patterns.html
%%
function prt_patterns(index)
%% created 2016/12/31 by Bas Kooijman
% modified 2021/02/20
%% Syntax
% <../prt_patterns *prt_patterns*>
%% Description
% generates plots for patterns for display on patterns.html
%
% Input:
%
% * index: opti... |
function [out, outDesc, outSortMat, sortIndexes] = ComputeBarPairResponseMatrix(roiAveragedResponses, barPairSortingStructure, barToCenter, mirrorCheck, optimalBar, numPhases, samplesAroundEpoch, roiPhaseShift, singleLengthsSeconds)
% We take in a mirrorCheck because everything gets mirrored for the left
% eye--we coul... |
function D=get_geodirs(dim,d)
s=get_pathname(dim,d);
assert(~isempty(s),'Unable to find geo directory for dim=%d and d=%d',dim,d)
env=fc_vfemp1.environment();
loc_dir=fullfile(env.Path,'geodir',s);
D=fc_simesh.get_geodirs(dim,d);
D={loc_dir,D{:}};
end
function s=get_pathname(dim,d)
if dim==2 && d==2
... |
%
% irpGetProjectorPlanes determines the normals and distances of every
% projector plane. The following variables need to be present in memory to
% execute successfully:
% - striped_calib1+2: the stripe images of the calibration planes
% - CTW1+2: the transformations from calibration coordinates to camera
% ... |
function [R, nablaR] = multiple_shooting(w_guess, ~)
global n_step ns nu state_coeff input_coeff s_fin
state_coeff_sqrt = sqrt(state_coeff);
input_coeff_sqrt = sqrt(input_coeff);
w_des = [kron(ones(n_step+1,1), s_fin) ; zeros(n_step*nu, 1)];
nablaR = [kron(eye(n_step+1),state_coeff_sqrt... |
function [ filescr ] = everysixth( file )
%This function creates a new file which contains only the data for the
%screening appointments
filescr = table;
for x = 1:6:height(file)
row = file(x,:);
filescr=[filescr; row];
end
end
|
function T=Tmatrix(n)
% Definiert eine Matrix mit Hauptdiagonalelemente T_ii = 2
% und Nebendiagonalelementen T_i,i-1 = T_i-1,i = -1
T=zeros(n,n);
.......
|
% Demo with the implementation of the point-target Poisson multi-Bernoulli mixture (PMBM)
% filter with negative binomial clutter described in
% A. F. Garcia-Fernandez, Y. Xia, L. Svensson, "Poisson multi-Bernoulli
% mixture filter with general target-generated measurements and arbitrary
% clutter", IEEE Transactions o... |
function [xNew, chi]=pointAlignerIteration(x,Z)
H=zeros(3,3);
b=zeros(3,1);
X=v2t(x);
chi=0;
#loop through the measurements and update the
#accumulators
for i=1:size(Z,2),
e=computeError(i,X,Z)
J=computeJacobian(i,X,Z);
H+=J'*J;
b+=J'*e;
chi+=e'*e;
end
dx=-H\b;
H
dX = v2t(dx)... |
%=====================================
% validate_accelmove - Boris routine and particle pusher
% Kevin Diomedi
%
% Boris acceleration and particle movement
%=====================================
err=1e-6;
%=====================================
% Particle movement
%=====================================
%fields all ze... |
%% Wireless Cuff Blood Pressure Detection
% Created by Evan Williams 3/26/17
% This script utilizes the dataset located at
% https://archive.ics.uci.edu/ml/datasets/Cuff-Less+Blood+Pressure+Estimation#
% to develop the signal processing required for our cuffless blood
% pressure estimator wearable that we ar... |
clear
disp('START')
disp(' ')
%载入信号
sacname = 'A101.L236.+.SAC';
fid = fopen(sacname);
rhdr = fread(fid,70,'real*4');
ihdr = fread(fid,40,'integer*4');
chdr = fread(fid,192,'char');
data = fread(fid,'real*4');
fclose(fid);
fprintf('The input file is %s\n',sacname)
fprintf('The DIST = %6.2fkm\n',rhdr(51))
fprintf('... |
function plotCut2(matrixID,matrixIA,frames,timeUnit)
saveMode = questdlg(['Would you like to save your traces as 4-column '...
'data (t, ID, IA,FRET) for QuB or as 2-column (ID,IA) for ebFRET?',...
], 'Select Save Mode','2','4','Both','4');
QuB = 1;
ebFRET = 1;
modes = {'QuB','ebFRET'};
... |
load 390177_WOA13_AnnualMean.mat
T1=0:30;
S1=0:40;
T=repmat(T1,[41 1]);
S=repmat(S1',[1 31]);
p=1000;
dens=sw_dens(S,T,p)-1000;
%s_an_1D=s_an(:);
%t_an_1D=t_an(:);
%%%% plotting
figure;
[c,h]=contour(S,T,dens,[0:2:40],'k');
clabel(c,h,'LabelSpacing',200,'FontSize',[12],'Rotation',0);
%making the figure nice:
axis([33 ... |
function [capSizeDAC, capSizeMAC] = getCapSizes(NOB,process_param, unitCap, capRatio, gainError, F_per_M)
unitArea = unitCap/F_per_M;
%% DAC
sum=0;
for i=0:NOB-2
sum = sum + (2^i);
end
%INL
minAreaINL = (6*process_param*sqrt(sum))^2;
capSizeDAC1 = minAreaINL*F_per_M;
%DNL
sum = sum + 2^(NOB-1);
minAreaDNL = (3*... |
% This function imputes unemployment insurance benefits for different US
% states. Special thanks to L. Pistaferri for sharing advice
% Copyright (C) 2018 Johannes Fleck; https://github.com/Jo-Fleck
% You may use this code for your own work and you may distribute it freely.
% No attribution is required. Please leave ... |
%example_evaluate.m
file_path = 'C:\Users\Dani\Documents\PhD\research\tasks\projects\GNC system architecture\OPN model\';
name = 'GNC_2types2.csv';
filename = [file_path name];
[architectures] = EvaluateGNC(filename);
% Create Output File
Narc = length(architectures);
m = zeros(Narc,1);
R = double(zeros... |
function w = altgwin(L, a)
%alternate gausswin
error(nargchk(1,2,nargin,'struct'));
% Default value for Alpha
if nargin < 2 || isempty(a),
a = 2.5;
end
% Check for valid window length (i.e., N < 0)
[L,w,trivialwin] = check_order(L);
if trivialwin, return, end;
% Compute window according to [1]
N = L-1;
n = (0:N... |
% Script to integrate the work flow of UWBRAD temperature estimation
% Yuna Duan March 24th based on Mike's seprated scripts
%% 1. Get UWBRAD Tb
% Average MEMLS Tb by antenna pattern file using function GetModelOutput
% Save result in dat/TbUWBRAD-v2
% Reorganize the data in the way shown in the numbers sheet
% Save... |
#! /usr/bin/octave -qf
1;
function show_something(x, h, titlelabel = '', it = 1, fase = 1)
x
iteraciones = length(h)
toc;
disp('-------------------------------------------------------------------');
show_something_helper(x, h, titlelabel, it);
end
function show_something_helper(x, h, titlelabel, it)
color... |
function smscan = createsmscan2
%function to create smscan
%second loop
smscan.loops(1).npoints=101;
smscan.loops(1).rng=[0.1,0];
smscan.loops(1).getchan={'field','K1dcv'};
smscan.loops(1).setchan={'field'};
smscan.loops(1).ramptime=-1;
smscan.loops(1).trigfn=[];
%each row of disp describes data to be displayed by... |
%Problem 10
m = imread('lena.png');
g = rgb2gray(m);
disp(strcat('Mean of the picture:' , num2str(mean(g,'all'))));
disp(strcat('Variance of the picture:', num2str(std2(g))));
maxelement = max(g,[],'all');
[maxX,maxY] = find(g == maxelement);
disp(strcat('Max element of the picture:',num2str(maxelement)));
disp(strcat(... |
%-------------------------------------------------------------------------
% batch file hrdp.m
%
% hrdcp.m concatenates all the navigation simulation files into
% one file for harcopy output.
%
% Demoz Gebre 7/5/98
%--------------------------------------------------------------------------
... |
%% Name: Sheel Nidhan
% To calculate the Reynolds stresses and its similarity
clear; clc; close all;
%% Parameters
loc_planes = [5; 10; 15; 20; 25; 30; 35; 40; 45; 50; 55; 60; 65; 70; 75; 80; 85; 90; 95; 100; 110; 120];
nstart = 1892600;
nend = 2613200;
stride = 100;
dir_in_planes = '/home/sheel/Work2/projects_dat... |
function nts
% NTS - Creates and opens a New Today Script to serve as a record of daily activities.
% This function creates a New Today Script (hence NTS), which is a script intended to serve as a log of daily research
% activities that take place in MATLAB. To this end, it automatically creates a new MATLAB .m scr... |
function [] PlotFace(Vert, Face)
nrFaces = size(Face,1);
nrVertices = size(Vert,1);
Patch.Vertices = Vert;
Patch.Faces = Face;
CDData = 0.3 * ones(nrFaces,1);
Patch.FaceVertexCData = CDData;
Patch.FaceColor = 'flat';
Patch.EdgeColor = 'red';
PlotNormals(Vert, Face);
end
|
close all; clc; clear
% This script computes the number of Nash equilibria in the information
% sharing game across parameter space of fidelities, (p,q) in (1/2,1)^2.
% This data is stored, and saved, in the file 'nash_abundance_kappa=5.mat'
% (similarly for kappa=1)
% % % % %
mydir = pwd; % get current directory
i... |
function X=Jacobi(A,b,N,delta,P)
%Input -A n*n非奇异矩阵
% -b n*1矩阵
% -N 最大迭代次数
% -delta 精确度
% -P n*1矩阵,初始值
%Output -X n*1使用Jacobi方法(分量形式)得到的方程组AX=b的解
%求维数
n=length(b);
%初始化X
X=zeros(n,1);
%k记录迭代次数
k=1;
while (k<=N)
for i=1:n
%计算新的值
X(i)=( b(i)- A(i,[1:i-1,i+1:n]) * P([1:i-1,i+1:n]... |
function run_pipeline(subject_num,date_str,startstep)
subject_str = sprintf('%03i',subject_num);
load('./params/params_settings.mat')
%% Parameters
params_settings.general.enable_preprocessing = 0;
params_settings.general.enable_RSVP = 1;
params_settings.general.enable_SSVEP = 0;
params_settings.general.enable_ERN = 0... |
close all;
clear;
clc;
%% Load Feature Matrix and their corresponding labels
plotStream=false;
loadStoredData=true;
iteration=3;
tempacc=zeros(2,iteration);
for itr=1:iteration
fprintf('\n\n\nIteration %d:\n',itr);
if loadStoredData
load NewSamples.mat; % load first s... |
%step1: Read th i/p image f(x,y) of size MxN and obtain the padding by
%setting parameterP and Q: P=2M , Q=2N
%step2: From a padded image fp(x,y) of size PxQ
%step3: Multiply fp(x,y) by (-1)^x+y
%step4: Compute DFT F(u,v) of image from step 3
%step5: Generate a real and symmetric filter function H(u,v)of s... |
function [] = delta_rule_steps_predict(inp, out, beta)
[m n] = size(inp);
w = [];
s = -1;
for (i = 1:n)
w(i) = rand(1);
end
e = 0;
while (e < 100)
for (i = 1:m)
y = 0;
for (j = 1:n)
y = y + inp(i,j) * w(j);
end
s = y;
error = out(i) - s;
for (j = 1:n)
... |
function [ flat ] = pflat( vek )
%PFLAT
% Divides each column by the last
%
% Alexander Karlsson 2015
flat = [];
for i = 1:size(vek,1)-1
a = rdivide(vek(i,:),vek(end,:));
flat = [flat; a];
end
flat = [flat; ones(1,length(vek(end,:)))];
end
|
function [output] = camel(x,y)
% output = (4-(2.1*(x^2))+((x^4)/3))*(x^2) + (x*y) + (-4+4*(y^2))*(y^2);
% x1 = x;
% x2 = y;
% fact1 = sin(x1)*cos(x2);
% fact2 = exp(abs(1 - sqrt(x1^2+x2^2)/pi));
% output = -abs(fact1*fact2);
output = -0.5*sin(x-pi/2)*sin(y-pi/2)+0.03*((x^2 + y^2))^(0.5);
end |
% University of British Columbia, Vancouver, 2017
% Alex Kyriazis
% William Choi
%one time use that converts the original unorganized files into an
%organized format with metadata that we could use. Probably no longer
%needed.
path = uigetdir('../../data/images','Open folder to organize');
out_path = uig... |
function [seasons, seasonName] = season_array(dateRange)
%SEASONS returns a N x 4 logical array with each column denoting if the
% date in dateRange is in Winter (DJF), Spring (MAM), Summer (JJA),
% or Fall (SON).
%
% Written by: Michael Hutchins
dates = datevec(dateRange);
months = dates(:,2);
seasons = false(le... |
clear
close all
%% For RDG: Algorithm that Mimics Human perceptual Grouping of Dot Patterns
% 2018
Data = load('C:\Users\pp\Desktop\clusteringDataset\Spiral.txt');
x = Data(:,1);
y = Data(:,2);
figure
plot(x, y, '.')
title('Unlabel Data')
%% bench mark
c = Data(:,3);
len_data = length(x);
len_class = length(unique(... |
function [points_out]=calc_intersection(object1,object2)
% straight = [A B] for y=A*x+B; if A=inf, then line_str(2)=x coord.
% curved = [x0 y0 R] for R^2=(x-x0)^2+(y-y0)^2
if isfield(object1,'A')
ID1='line';
A1=object1.A;
B1=object1.B;
elseif isfield(object1,'R')
ID1='circle';
x0=object1.ce... |
classdef Kmeans < handle & Learner
%TODO : lite seems to be better? change to formal setting in the future?
% kihyuk's library has a pretty nice function
properties
weights; %feadim*numunits
feadim;
numunits;
ty... |
function [prediction] = UserBasedKNN(datasetName,userId,movieId)
Data = readmatrix(datasetName);
[Edited] = Edit(Data);
userRates=Edited(userId,:);
[AllDistancesOther] = CorrelationForNew(Edited,userRates);
[a,index] = sort(AllDistancesOther(1,:),'descend');
[guess] = calcPrediction(a,index,Edited,userRates,50,movieId... |
function [H, errs, grads, ts, k] = TPM(A, options)
options_I.lambda = options.lambda;
options_I.timelimit = options.timelimit;
options_I.ac = options.ac;
options_I.init = options.init; [H,errs_I,grads_I,ts_I] = Phase_I(A,options_I);
options_II.timelimit = options.timelimit; options_II.t_old = ts_I(end);
options_II.... |
%exam5-3
%17-67
l = input("length of bar in m: ");
f = input("force applied at the end of the bar in N: ");
mass = input("mass of bar in kg: ");
Ig = mass*l*l/12 + mass*(l/2).^2;
alpha = (f*l + mass*9.81*l/2) / Ig;
sprintf("angular acceleration of rod is %.3f rad/ss", alpha) |
%A more advanced simulation which takes into account the state of the other
%channel when determining transition probability. Can be generalized to
%more channels. See also mdMarkovTest
N = 10; %number of traces to create
lengthTrace = 1000; %length of each trace in time points
cy3Final = cell([N 1]);
cy5Final = cel... |
%% Stelling 8
%
% De equality-operator komt in twee vormen:
%
% 1 - ==
% 2 - eq()
%
Antwoord = NaN; % vul hier het juiste antwoord in 1 (WAAR) of 0 (ONWAAR)
|
clear all
clc
tic
%% plot array pattern
f=1*10^9;
c=physconst('LightSpeed');
lamda=c/f;
d=lamda/2;
L=17;
r=[-4*d -3*d -2*d -d d 2*d 3*d 4*d];
R=[r zeros(1,8) 0;zeros(1,8) r 0];
theta=linspace(pi,-pi,1000);
v=[cos(theta);sin(theta)];
tao=[];
s=[];
for l=1:L
tao(l,:)=R(:,l)'*v/c;
s(l,:)=exp(1j*2*pi*f*tao(l,:));
e... |
function h = zonal_fluctuation(g)
% This function returns the fluctuating part of field.
% h is g minus zonal averaged g
% f must be in polar grid
h = g - repmat(zonal_average(g), 1, size(g,2), size(g,3));
|
clear;
close all;
clc;
STEPSIZE = 0.01;
NUM_NODES = 100;
f = 0:STEPSIZE:1;
numTestValues = length(f);
statistics = zeros(numTestValues, 4);
numExperiments = 50;
parfor i = 1:numTestValues
for j = 1:numExperiments
adjacencyMatrix = GenerateERGraph(NUM_NODES, 0.15);
adjacencyMatrix = RemoveFraction(adjacencyM... |
function [T_TOTAL,OTHEROUT] = analysis(file,path_file,nLabImp,isMICRO,MOD_TYPE,varargin)
%******************************************************************************************
%* PROGRAMA DE ELEMENTOS FINITOS PARA LA RESOLUCION DE PROBLEMAS EN MECANICA DE SOLIDOS *
%* ... |
function [K_glo_mat_imp,C_glo_mat_imp,M_glo_mat_imp]=impeller_diffuser(N,rho_fluid,imp_dia,exit_width,imp_node,tot_node)
K_glo_mat_imp=zeros(4*tot_node);
C_glo_mat_imp=zeros(4*tot_node);
M_glo_mat_imp=zeros(4*tot_node);
w=2*pi*N/60;
% Dimensionless coefficients
K_star = -4.2;
k_star = 5.1;
C_star = 4.6;
c_star = 13.5... |
function B=nancumsum(A,dim,nmode)
% NANCUMSUM: Cumulative sum of a matrix, with user-specified treatment of NaNs.
% Computes the cumulative sum of matrix A along dimension DIM, allowing
% the user to replace NaNs with zeros, to maintain NaNs as
% placeholders, or, when A is a vector, to discard NaNs.
%
%... |
function expt = getExperimentList
n = 0;
n = n + 1;
expt(n).animal = 'M151104A_JF';
expt(n).series = {126};
expt(n).exp = {[101:105]};
expt(n).area = {'CA1'};
expt(n).CA1 = {1};
expt(n).goodCA1 = {1};
expt(n).goodCA1dec{1} = {1};
expt(n).goodCA1dec{2} = {1};
expt(n).goodCA1dec{3} = {1};
expt(n).V1 = {0};
expt(n).goodV... |
function [practice] = prae_getstimuliPractice(stims,n_trials,n_trials_block)
%-------------------------------------------------------------------------%
% [practice] = repref_getstimuliPhase1Practice(...)
%
% * all arguments must be specificed in repref_getstimuli
%
%---------------------------------------... |
classdef CodeTest < matlab.unittest.TestCase
%Tester for unit testing for refactoring
% Detailed explanation goes here
properties
% TableHR
% StorageHR
% TableBR
% StorageBR
sg3P
sh3P
adjustedSol
end
methods (TestClassSetup... |
function [userdata,direction] = Snakes2(position,arena,userdata)
[m,n]=size(arena);
minrange=10000;
for x = 1:m
for y = 1:n
if arena(x,y)==7
range=abs(position(2)-x)+abs(position(1)-y);
if range<minrange
minrange=range;
minx=x;
miny=y;
end
end... |
slurmOpts = slurmBatch;
slurmOpts.memory = 1.5;
slurmOpts.cpus = 1;
slurmOpts.partition = 'all'
jids = [];
nTests = 10;
for ii = 1:nTests
comStr = sprintf('startup; pause(30); disp(''job %d complete'')',ii);
slurmOpts.name = sprintf('test_%d',ii);
slurmBatch(comStr,slurmOpts);
end |
function robot = CreatePuma560()
%% robot = CreatePuma560()
% Creates a robot model of the Puma560 that is compatible with the
% spatial_v2 dynamics library.
a2 = .2;
d3 = .4;
a3 = .153;
d4 = .839;
aa2 = sym('a2','real');
aa3 = sym('a3','real');
dd3 = sym('d3','real');
dd4 = sym('d4','real');
% Modified Denavit Har... |
function plot_3Dgraph(X, C, W, y)
W(W <1e-5) = 0;
[iidx, jidx, val] = find(sparse(W));
% fprintf ('%d, %d, %f\n', [iidx, jidx, val]');
figure;
hold on;
plot3(C(1,:), C(2,:), C(3,:),'or');
for i=1:length(iidx)
plot3( [C(1, iidx(i)), C(1, jidx(i))], [C(2, iidx(i)), C(2, jidx(i))],...
[C(3, iidx(i)), C... |
function [grampc,Tsim,grampc_sdata] = initData_OCP()
% This function initializes a grampc struct in MATLAB and sets parameters
% and options. In case of three output arguments the struct grampc_sdata for
% the use in Simulink is created as well. Define all options and parameters
% for the use of GRAMPC in MATLAB here.... |
% RevisedSimplexMethod solves Linear Programming Problems (LPP) in canonical
% form of LPP in standard form:
%
% Max $$ z = \mathbf{c}^T*\mathbf{x} $$
%
% subject to
%
% $$ \mathbf{A*x} \leq \mathbf{b} $$
%
% $$ \mathbf{x} \geq \mathbf{0} $$
%
% INPUT: A, b, and c
function [z, xB, xB_idx] = RevisedSimplexMethod... |
function [r1, r2, r3] = crisg4_bandsplit(id, rad);
% function [r1, r2, r3] = crisg4_bandsplit(id, rad);
%
% Split a CrIS g4 radiance array into separate arrays for each of
% the three CrIS bands, with the guard channels appended to the
% ends of each band (ie sorted by freq).
%
% Input:
% id - [1329 x 1] channel ... |
function [x, it, it_line_search, nfe, time] = mod_newton(fun_obj,x0)
% Modified Newton Method with a line search:
% H_k is replaced by B_k = H_k + lambda*I, where lambda is chosen in an
% iterative way, starting from lambda = 1 and increasing its value in 1
% until B_k is d.p
tic
% Linesearch-Parameters:
bet... |
close all; clear; clc;
A = imread('Kasus10.jpg');
B = imread('bwShedKasus10.jpg');
B = im2bw(B);
C = imageSeg2rgb(A,B);
[L,num] = bwlabel(B);
MeanR = regionprops('table',L, C(:,:,1), 'MeanIntensity');
MeanG = regionprops('table',L, C(:,:,2), 'MeanIntensity');
MeanB = regionprops('table',L, C(:,:,3), 'MeanIntensity');... |
% Tests the Algorithm for Pedestrian Paths
% Code by: Nitin J. Sanket (nitinsan@seas.upenn.edu)
% NOTE: CLEARS WORKSPACE!
clc
clear all
close all
load('PedestrianModel.mat');
addpath(genpath('./'));
I = im2double(imread('aerial_colorResized.jpg'));
disp('Welcome to Pedestrian Path Planner, Press Enter to continue....'... |
function Crow = coriolis_row_1(rob,in2,in3)
%% CORIOLIS_ROW_1 - Computation of the robot specific Coriolis matrix row for joint 1 of 5.
% =========================================================================
%
% Crow = coriolis_row_1(rob,q,qd)
% Crow = rob.coriolis_row_1(q,qd)
%
% Description::
... |
% cost per pair for dynamic time warping
% return euclidean distance
function cost = get_cost(p1, p2)
diff = p1 - p2;
diff = diff .* diff;
cost = sqrt(sum(diff));
end |
%%
%
% Head velocity in X
%
function out = fcnXVel( tA, tAIX)
samplePeriod = .05;
% headPosX = bodyX + headX;
headPosX = squeeze(tA(:,:,1) +...
tA(:,:,3));
headPosY = squeeze(tA(:,:,2) +...
tA(:,:,4));
% Flip traces in X if necessary ... |
% Evaluation code of the PRW dataset.
% This code will evaluate the DPM detector (pre-trained on INRIA dataset, denoted as DPM_Inria in our paper) plus the BoW+XQDA recognizer.
% If you find our code helpful in your research, please kindly cite our
% paper as
% Liang Zheng, Hengheng Zhang, Shaoyan Sun, Manmohan Ch... |
% Calculate position vector for OL to TE/DE
% %RN%
% Use Code from Maple symbolic Code Generation
%
% Input:
%
% Output:
% posNQJ[%NJ%x1]
% position vector
% %VERSIONINFO%
function posNQJ = %FN%()
|
function err = mseLossFunc(x, y)
% ERR = MSELOSSFUNC(X,Y) calculates the mean-squared error (MSE) between
% the arrays X and Y.
assert(all(size(x) == size(y)), 'mseLossFunc: Array dimensions are not equal.')
err = (norm(x(:)-y(:), 2).^2) / numel(x);
end
|
classdef Highway < handle
%HIGHWAY Models the highway as a snapshot and its transitions
properties
nLanes
nCells
highway
tempHighway
rng
speedLimit
useCellfun
indices
end
methods
function obj = Highway(nLanes, nCells, rng... |
classdef laufkatze_teach_hub_classdef < matlab.System
% Motorsteuerung2 Skript zum automatisierten Teaching der Absolutwertdrehgeber
%
% Laufkatze bzw. Greifer muss sich zum Start ungef?hr in der Mitte befinden
% Public, tunable properties
properties
end
properties(Nontuna... |
function s = setfields(s, field_names, values, cond)
% Set the name of functions for the domain.
%
% The usage is similar to set/get function of
% matlab.mixin.SetGet class.
%
% @author ayonga @date 2016-12-01
%
% Parameters:
% s: a structure of type struct
% fields: a string o... |
% absolute: trueRange points on left and trueRange points on right are accepted
% percent: %trueRange points on left and %trueRange points on right are accepted
function [matrix] = resultAnalyser (numOfPoints, mode, trueRange)
% mode detection
if strcmp(mode, 'absolute') == 1
halfRange = trueRange;
elseif strcmp(... |
function vout = nanshift(vin,s)
% like circshift, but padds with nans instead of shifted values
% Shift data
vout = circshift(vin,s);
% Change leaked values to nans
if s > 0 % we shifted forward so
vout(1:s) = nan;
elseif s < 0 % we shifted backwards so
vout(end+s+1:end) = nan; % s is negative so we have to a... |
clear;
data=xlsread('data.csv');
x=data(:,3);
y=data(:,4);
plot(x,y);
grid on
xlim([0,639])
ylim([0,479]) |
clc, clear all, close all
ts = 14;
b = [1 1];
a = [1 -0.25838];
[h,w] = freqz(b,a,1024);
figure;
subplot(2,1,1);
plot(w,mag2db(abs(h)),'b','linewidth',2);
grid on;
set(gca,'GridLineStyle','-');
axis tight;
xlabel('\omega','fontsize',ts);
ylabel('|H_d(\omega)|','fontsize',ts);
set(gca,'xtick',[0 pi/4 pi/2 3*pi/4 pi]); ... |
% Fuselage sizing code was an initial code used to identify the required
% length of the aircraft for the fuel needed alongisde important
% considerations such as cabin length, hold size. A plot was formed showing
% the locations of fuel, cabin and hold in the aircraft.
% Initialisation
clear all
close all
fclose('all... |
d = 1;
n = 100;
load('');
x1 = [x(:,1) - d/2, x(:,2), x(:,3)];
x2 = [x(:,1) + d/2, x(:,2), x(:,3)];
xt = [x1;x2];
min = 100000;
for i = 1:n
for j = 1:n
d = sqrt((x1(i,1)-x2(j,1))^2+(x1(i,2)-x2(j,2))^2+(x1(i,3)-x2(j,3))^2);
if d < min
min = d;
end
end
end
min
%savefile = 'Two_... |
function [ featureManipulator ] = specifyFeatureManipulator(trainer)
%Reed Gurchiek, 2019
% select feature manipulator to use in initializeBinaryClassifier
%
%----------------------------------INPUTS----------------------------------
%
% trainer:
% trainer struct from initializeBinaryClassifier
%
%-----------... |
function data = txtbinfile(fname)
% Convert '.txt' or '.dat' to '.bin' file.
%
% Prototype: data = matbinfile(fname, varname, clm)
% Inputs: fname - file name, with extension '.txt' or '.dat'
% Output: data - data array read from the '.txt' file
% See also matbinfile.
% Copyright(c) 2009-2020, by Gongmin Yan, All ri... |
%Machine Learning
%Ben Larson
%% Import data from text file.
% Script for importing data from the following text file:
%
% /Users/Benjamin/Documents/MACHINE_LEARNING/hw2/a1a.train
%
% To extend the code to different selected data or a different text file,
% generate a function instead of a script.
% Auto-generated... |
clc; clear;
cd('C:\Users\will\Documents\CEMNL\Testing Differentially Strengthens Recovery\runfiles\');
content=dir;
ignore_list={'.' , '..' , '.git' , 'hooks', 'common'};
dirs=content(cellfun(@isdir,{content(:).name}));
dirs_list=arrayfun(@(i) dirs(i).name, 1:numel(dirs),'UniformOutput',false);
experiments=setdif... |
startX = 0;
startV = .1;
g = 9.805;
l = 10;
k = g/l;
c = 0.0;
dt = 0.01;
x = startX;
v = startV;
a = -k*sin(x)
X = [];
V = [];
A = [];
T = 0:dt:10;
for t = T
X = [X;x];
V = [V;v];
A = [A;a];
v = v+a*dt;
x = x+v*dt;
a = -k*sin(x) - c*(v*l)^2*sign(v);
end
plot(T,X,'r', T,V,'b', T,A,'g' ,T,zeros(1,... |
% --------------------------------------------------------------
% Compute capacitance per unit length of
% a coaxial pair of rectangles
% --------------------------------------------------------------
% -- Provided code: Adjusted by Axel Trange
function cap = capacitor_matrix(a, b, c, d, n, tol, rel)
% Argume... |
function [ q_out ] = quat_rotate( Xr, Yr, Zr, q_bottom, dt )
%QUAT_ROTATE Rotate a quaternion by a velocity and timestep.
% Switch to scalar top, because that's what this code was written for
q = zeros(4,1);
q(1) = q_bottom(4); % w -x
q(2) = -q_bottom(1); % x -y
q(3) = -q_bottom(2); ... |
function spcout = spc_calcBinning(spc)
xw = spc.size(2);
yw = spc.size(3);
spc.imageMod = spc.imageMod(:,:,1:2:xw,1:2:yw) + spc.imageMod(:,:,2:2:xw,1:2:yw)...
+ spc.imageMod(:,1:2:xw,2:2:yw) + spc.imageMod(:,2:2:xw,2:2:yw);
spc.size(2)=round(spc.size(2)/2);
spc.size(3)=round(spc.size(3)/2);
spc.project = reshape(s... |
%% Preambule
%% [Call, Put] = mcPricer(100,30,11,0.02,0.2,12,82)
% Dit script heb ik gemaakt zodat alle codes in 1x kunnen runnen
% terwijl ik slaap. Ik denk dat zoiets ook slim is voor als we
% in de volgende assignment gaan brute force optimaliseren ;)
N = 200;
trials = 30;
aMu=0.02;
aSigmaVol=0.2;
aTVol=82;
yield=... |
function [F3]=rF3(phi,theta_0,r,varphi,vartheta,rho,pln,Dtg,t,i,Gpoly,kpeo,kpmpc,nhat)
f9=uPsi(phi,0,r,varphi,vartheta,rho,pln,Dtg,t,i,Gpoly).*uV2(phi,0,r,varphi,vartheta,rho).*r.*sin(phi).*nhat(1);
f10=uPsi(phi,theta_0,r,varphi,vartheta,rho,pln,Dtg,t,i,Gpoly).*uV2(phi,theta_0,r,varphi,vartheta,rho).*r.*sin(phi);
f15=-... |
clc
clear all
close all
warning off;
% Try to combine features
I = im2double(imread('../aerial_colorResized.jpg'));
addpath(genpath('../'));
[F(:,:,1),~] = BrightRoofsYCbCr(I);
[F(:,:,2),~] = DarkShadowsYCbCr(I);
[F(:,:,3),~] = GreenAndGrayRoofsYCbCr(I);
[F(:,:,4),~] = GreenYCbCr(I);
[F(:,:,5),~] = RedYCbCr(I);
[F(:,:... |
function rect_q5()
% PRIOR KNOWNS:
% Masses of Blocks [kg]:
mb1 = 490.5e-3;
mb2 = 485.5e-3;
mb3 = 240.5e-3;
mb6 = 490.5e-3;
Mc = mean([0.768, 0.672, 0.553]); % Mean of Cart Masses Determined in Lab 1
% Known Masses for Each Experiment:
M(1) = Mc + mb1 + mb2 + mb3 + mb6;
M(2... |
function sq = closest_points(latMap,lonMap,idxLat,idxLon,Lat,Lon)
%This function returns the square with the 4 closest points to the chosen
%location
% INPUT: 1x1 Lat: Latitude of the chosen location
% 1x1 Lon: Longitude of the chosen location
% 1x1 idxLat: Index of chosen locatio... |
%% Task 3: Create and view custom neural networks.
%% 1) Define sample data (i.e. inputs and outputs).
inputs = [1:6]; % input vector (6-dimensional pattern); i.e. 1 2 3 4 5 6
outputs = [7:12]; % corresponding target output vector; i.e. 7 8 9 10 11 12
%% 2) Define and custom the network
% create the network: 1 input,... |
% Brandes Algorithm for Betweenness Centrality %
% Author: Konstantinos Sotiropoulos %
% Import: NXN adjacency matrix %
% Export: 1XN betweenness centrality for every graph node
function BC=brandesBetwCentr(adjMatrix)
nodesNumber = length( adjMatrix );
%% Pre-Processing of Adjacency Matrix
pSize = max(su... |
function a = sumf2(p)
a = sum(abs(p).^2, 'all');
end
|
function [] = write_video(video, file, arr)
fps = 5;
format_file = 'Motion JPEG AVI';
v = VideoWriter(file, format_file);
v.FrameRate = fps;
open(v);
for i = 1:size(video,4)
text_str = ['Value ' num2str(arr(i))];
RGB = insertText(video(:,:,:,i),[100 100],text_str,'FontSize',18);
writeVideo(v,RGB);
end
close(v); |
function board = parse_fen(fen)
fen = char(fen);
board = repmat('*', 8, 8);
x = 1;
y = 1;
for i = 1:numel(fen)
c = fen(i);
% Controlla se è un numero.
if isstrprop(c, 'digit')
assert(x <= 8 && y <= 8, 'Riga della scacchiera troppo lunga.');
... |
function [ x,y,z ] = randomstep(length)
%RANDOMSTEP Produces a step in a random direction.
% Produces a step of length distributed exponetially about the mean free
% path. The direction is decided by random numbers.
r=-length*log(rand); %Length of the vector
%Direction
theta= asin(2*rand-1)-pi/2; %To prevent conce... |
% Function that estimates gradients for Algo 2
% obj = objective function
% x = input istance
% m = number of gradient directions (only for I-RDSA)
% t = current iteration
% mode = 0: KWSA, 1:RDSA, 2:I-RDSA
function g = grad_est_google(obj, x, t, m, mode)
d = length(x);
g = zeros(d, 1);
if mode == 0
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.