text stringlengths 8 6.12M |
|---|
function [x0, z0, ban, iter] = mSimplexRobusto(A, b, c)
%purpose: Versión del Simplex más Robusto
% minimizar c^T x
% sujeto a Ax <= b , x >= 0 , b en R^m
%
% In : A ... mxn matrix
% b ... column vector with as many rows as A
% c ... column vector with as many entries as one row of A
%
% Out: xo ... SFB óptima... |
%% Stelling 12
%
% Als je programma is gestopt m.b.v. een breakpoint dan
% kan je niet de variabelen in de Workspace niet bekijken.
%
Antwoord = 0;
|
function [snips, range] = readFromAllChannels(snipfile, sniptype, num, channels)
% FUNCTION [nsnips, range] = readFromAllChannels(snipfile, sniptype, num, channels)
%
% Read and return snippets of the given type from the given file, and the range
% of the snippets, i.e., the number of samples before and after a spike p... |
%Resolve prior variables
function toFile(fname)
%Run the function
answer = read_complex_binary(fname);
%Write to another file
fileID = fopen(strrep(fname,'.dat','.txt'), 'wt');
i = 1;
while(1)
try
fprintf(fileID, '%f\n', answer(i));
fprintf(fileID, '%f\n',... |
% Find the inductance per km of a 3-phase transmission line using 1·24 cm diameter conductors
% when these are placed at the corners of an equilateral triangle of each side 2 m.
clc;
clear all;
D = input("Enter the distance between the two conductors (in meters): ");
D = D*100;
d = input("Enter the value of co... |
function vbm_results(path_to_spm, rootpath, T1file, significance, normprefix, id)
% vbm_results(path_to_spm, rootpath, T1file, significance)
% Automagically print VBM analysis results onto png images.
% Significance is either unc or fdr
% Tested on SPM12 and SPM8
% STEPHEN KARL LARROQUE
% v0.2.1
% 2017-2019
% LICENSE: ... |
%% Demonstrate hyperbolic solvers
function hyper_demo()
close all;
global s;
a = 0;
b = 1;
N = 80;
x = linspace(a,b,N+1);
xf = linspace(a,b,201);
dx = (b-a)/N;
s = 1; % wave speed
init_cond = @periodic_wave;
cfl = 0.9;
dt_stable = cfl*dx/s;
Tfinal = 2;
Nfinal =... |
function z = p_to_z_two_tailed(p, sign_z)
%Z_TO_P_TWO_TAILED convert p-value to standard z-value in two-tailed test
%
% Z = Z_TO_P_TWO_TAILED(P, SIGN_Z) converts P to standard Z-values,
% interpreting P as a two-tailed p-value. Z values are returned with
% signs provided in SIGN_Z.
if nargin < 2 || isempty... |
function [abort] = keepFixating(fixationThreshold)
evt = Eyelink('NewestFloatSample');
if eye_used == -1; eye_used = Eyelink('EyeAvailable');
if eye_used == el.BINOCULAR; eye_used = el.LEFT_EYE;
end
end
Eyex = evt.gx(eye_used+1); Eyey = evt.gy(eye_used+1);
A= min(Eyex, xCenter); B= max(Eyex, xCenter);
C= min(Ey... |
clc;clear;close all;
%% 初始化
xi = [3 4 5 6 7 8 9];
yi = [2.01 2.98 3.50 5.02 5.47 6.02 7.05];
x = 3:0.01:9;
%% 多项式形式
y_2 = nearin(xi,yi,2,x,1);y_3 = nearin(xi,yi,3,x,1);
y_5 = nearin(xi,yi,5,x,1);y_6 = nearin(xi,yi,6,x,1);
figure,plot(xi,yi,'.',x,y_2,x,y_3,'--',x,y_5,':',x,y_6,'-.','LineWidth',1.2...
,'MarkerSize',1... |
function y = tg_sig(n)
y = (exp(n) - exp(-n))./(exp(n) + exp(-n)); %función tangecial sigmoide para activar neurona
end |
function potential = nonlinear_potential( params, xgrid )
% TODO:
%
% INPUT:
%
[~, alpha] = parse_params(params);
potential = -(1 + alpha * (xgrid .^ 2));
end
|
%Prob. 4(c)
w = linspace(-pi, pi, 50);
b1 = [1 -6 10 2 -15];
a1 = [1 15 100 370 744 720];
h1 = freqs(b1, a1, w);
figure
subplot(2, 1, 1)
plot(w, abs(h1))
title('magnitude of H')
xlabel('w')
ylabel('|H|')
subplot(2, 1, 2)
plot(w, angle(h1))
title('phase of H')
xlabel('w')
ylabel('°ÁH')
z1 = [3 1 2+i 2-i]';
p1 = [5 3+3... |
function [A] = ZbudujA(n)
%ZBUDUJA Buduje pełną reprezentację macierzy A z zadania
A = zeros(n);
for i=1:n-1
A(i, i) = 4;
A(i, i+1) = 1;
A(i+1, i) = 1;
end
A(n, n) = 4;
end
|
% Daniel S. Standage
% BCB 570
% 26 Mar 2012
%
% Adapted from a script written by D.J. Higham, accessed at
% http://personal.strath.ac.uk/d.j.higham/chem/ssa_plot.m
clf
rand('state',100)
% Define stoichiometric matrix
V = [ 1 0 -1 0 0 0 0 0 0 0 0 0;
0 1 0 -1 0 0 0 0 0 0 0... |
function [radius, nodeRadiusList] = getRadiusList(self, structure)
[Cn, Nd] = self.generateCnAndNdList(structure);
radius = sqrt(structure(:, 7) / pi);
nodeRadiusList = zeros(size(Nd, 1), 1);
for i = 1 : size(structure, 1)
if nodeRadiusList(Cn(i, 1)) < radius(i)
nodeRadiusList(C... |
a=C6{1};
b=C6{49};
c=C6{120};
d=C6{145};
figure(1);
subplot(2,1,1);
plot(a)
title('white noise');
subplot(2,1,2);
plot(b)
title('white noise ');
figure(2);
subplot(2,1,1);
plot(c)
title(' sinoidal+Random');
subplot(2,1,2);
plot(d)
title('sinoidal+Random');
|
function [ des_lut ] = getDesinusoids( dmb, wb )
%getDesinusoids Determines the desinusoid files to use based on the fov information in dmb
% The goal here is to read in the desinusoid files, read which files were used, then get the
% fov information from those files in order to match the fov to the desinusoid f... |
% test for Hessian based metrics
path(path,'mex/');
path(path,'toolbox/');
if not(exist('mode'))
mode = 'isotropic';
mode = 'anisotropic';
end
rep = ['results/hessian/' mode '/'];
if not(exist(rep))
mkdir(rep);
end
%%
% Load a smooth image.
n = 400;
sigma = 15 * n/200;
options.bound = 'per';
randn('state', 12... |
function out = convertPRODAS(infile,outfile,units)
%function out = convertPRODAS(infile,outfile)
%%This will take in a prodas file Convert everything to
%normal aerospace convention and output it to a file in
%english units
%%Forces and moments in inertial frame (Forces do include gravity)
%units = 2; %1 for SI and ... |
clearvars
addpath('trajectory')
addpath('constraint_funcs')
addpath('floquet')
addpath('solutions')
load('3DOF_eight.mat');
ac = aircraft(); ac.tf = t(end); ac.VR = VR; ac.N = 8;
% retrieve coeffs
ac.coeffs = get_coeffs([x,y,z], ac.tf, ac.N);
tspan = [ac.tf/4, 10*ac.tf];
sig_0 = get_traj(tspan(1), ac.tf, ac.coeffs,... |
function collectDataSequence(dim,ssize)
% -------------------------------------------------------------------------
% Preliminaries
localSetup; % Run script with local setup
FILENAME = ['_D' num2str(dim) '_C' num2str(ssize) '.mat']; % Parameters of the experime... |
%% Gaussian function
function [f] = gaussian(sigma, n, k)
%%
% sigma - standard deviation
% n - size of the mesh
% k - size of kernel
% [x,y] = meshgrid(-n:n, -n:n);
% f = exp(-x.^2/(2*sigma^2)-y.^2/(2*sigma^2));
% surf(x,y,f)
%%
f=zeros(n,n);
for i=1:n
for j=1:n
f(i,j)=(-1/2*pi*sigma^2)*exp(((i-(k+1))^2 + ... |
function util_set_xtick( rate, bin )
%UTIL_SET_XTICK Set X axis by bin-width and numbers.
% Rate: The bin array (we use the length of it, i.e. bin numbers)
% Bin: Bin width.
%
% Created on May/16/2011 By Pu Jiangbo
% Britton Chance Center for Biomedical Photonics
% Get X Range
range = length(rate... |
%{
pupil.TrialNoiseCorr (computed) # covariance of response variability
-> reso.TrialTraceSet
-> pupil.TrialSet
-----
cov_matrix : longblob # noise covariance matrix conditioned on pupil phase
%}
classdef TrialNoiseCorr < dj.Relvar & dj.AutoPopulate
properties
popRel = reso.TrialTraceSet*pupil.Trial... |
function [kden,N,K] = density_dir(CIJ)
%DENSITY Density
%
% kden = density_dir(CIJ);
% [kden,N,K] = density_dir(CIJ);
%
% Density is the fraction of present connections to possible connections.
%
% Input: CIJ, directed (weighted/binary) connection matrix
%
% Output: kden, density
% ... |
%
% Simple LSM with Ridge regression
%
clear all
close all
% Read data from FFP.txt to build prediction matrix
data_folder = '/home/papalotl/Dropbox/LSM-data/Data_3.0_1';
[Points,npoints,tris,ntris,indexes,dv,pv,nb,ka,FFmat]=...
readff(1,data_folder);
A=zeros(2*nb,2*nb);
b=zeros(2*nb,1);
% Compute weights w for q... |
f = 0:0.1:50;
a = 10;
X = 1./(a + j*2*pi*f);
% Gráfica para el espectro de magnitud
subplot(211)
plot(f, abs(X), 'linewidth', 2)
title('Espectro de la magnitud')
xlabel('Frecuencia (Hz)')
ylabel("|X(f)|")
grid on
% Gráfica para el espectro de la fase
subplot(212)
plot(f, angle(X), 'linewidth', 2)
title('Espectro de l... |
%------------------------------------------------------------------
% Vannelli & Vidyasagar Example 1 with VS Iteration Initialized with Vlin
% Compute an estimate of the region of attraction for Vannelli and
% Vidyasagar example 1 using the V-S iteration. The iteration is
% initialized with the Lyapunov functi... |
function [] = PostTraitement2( ImgInit , ImgBW, Contours, showSteps )
% * Fonction de post traitement de l'image
% * Permet de dessiner les bounding box sur les voitures (et peut etre
% * trouver les couleurs)
% * ImgInit => image en couleur de départ, pour tracer les BB
% * ImgBW => image en Noir et Blanc après les t... |
function [CorrectWPRecognition] = IsWPRecognizedCorrectly(WPResults,WordPart)
%ISWPRECOGNIZEDCORRECTLY Summary of this function goes here
% Detailed explanation goes here
CorrectWPRecognition=true;
numSegmentationPoints = length(WPResults);
if (numSegmentationPoints~=size(WordPart,2))
CorrectWPRecogniti... |
function net = pval_2_edge(pval)
% PVAL_2_EDGE takes in a matrix of pvalues of size N1 x N2 x T and uses FDR to convert to
% binary matrix. Computes for each t in T and ignores NaN inputs. Keeps only the smallest
% (i.e., most significant) p-values. The following bit of code thresholds
% the p-values using the FDR me... |
function varargout = simulinkplot( varargin )
%生成Simulink的仿真结果并绘图。
% 输入参数依次为:仿真名,时间序列,第一个信号名,第一个信号,
% 第二个信号名,第二个信号,……
ds = Simulink.SimulationData.Dataset();
ds.Name = varargin{1};
t = varargin{2};
for i=3:2:nargin
name = varargin{i};
data = varargin{i+1};
... |
function ad = monthAverage(time, data)
%% Extract year, month day and hour components of the datenum vector
dateVector = datevec(time);
[~,~,groups]=unique(dateVector(:,1:2),'rows');
ad.mean = accumarray(groups, data, [], @nanmean);
ad.time = accumarray(groups, time, [], @nanmean);
end
|
function [accuracy]=DCcrossValidation(mdl)
cvtree=crossval(mdl); %Apply cross validation of the model
cvloss = kfoldLoss(cvtree); % find the accuracy after running the cross validation
accuracy=1-cvloss;
end |
%% GET ALL THE PROC directories with functional volumes coming from sessions.
celldisp(cellstr(EXPERIMENT_DIR));
% get all subject dirs
dirs = dir('./s*');
% List of open inputs
% Named Directory Selector: Directory - cfg_files
nrun = size(dirs,1); % enter the number of runs here
jobfile = {strcat(CODE_PATH, '/fun... |
%
% Over-complete dictionary assembly and
% simutanously pixel clustering via NMF
%
% by Feng Xu
% Fudan University, EMW Lab
% fengxu@fudan.edu.cn
% GNU General Public License v3.0
%
% Notation:
% C: Input Covariance Matrix
% T: Coherency Matrix
% H: Height of the image
% W: Width of... |
clc; clear; close all;
img = rgb2gray(imread('lena.jpg'));
subplot(1,2,1);
imshow(img);
title('Grayscale');
img = double(img);
[U, S, V] = svd(img);
I = uint8(U*S*V');
subplot(1,2,2);
imshow(I);
title('Reconstructed from USV values'); |
%% Declaration of Authoriship
% This code was written by Jason K. George
% for the purpose of his final year project at Stellenbosch University
% in partial completion for the subject Project (E) 448
%% Code
function y = calIntError3(calPhase,simulated, phasor_array)
simulated = (simulated)/abs(max(simulated));
Nscans... |
% connect mongo on localhost and use BMI database
mongoconn = mongo("localhost",27017,"BMI") |
function [ states ] = FSMC_states( control,SNR,SNR_thres,nr_states )
%This function returns a vector that contains the FSMC states that the
%channel is at. In order to do that, the
%function requires the SNR thresholds between the states.
% INPUT: m x 1 SNR: vector containing the SNR values
% n x 1 ... |
%[2019]-"Harris hawks optimization: Algorithm and applications"
% (8/12/2020)
function HHO = jHarrisHawksOptimization(feat,label,opts)
% Parameters
lb = 0;
ub = 1;
thres = 0.5;
beta = 1.5; % levy component
if isfield(opts,'T'), max_Iter = opts.T; end
if isfield(opts,'N'), N = opts.N; end
if i... |
% Kaja Coraor
% Comp 590
% Assignment 3
clear all
% Read image, make it smaller
im = imread('Good_Photos/IMG_2088.JPG');
im = imresize(im, 0.1);
% Get red and blue channels
R = im(:,:,1);
G = im(:,:,2);
B = im(:,:,3);
% get edges
Redge = edge(R, 'sobel');
Bedge = edge(B, 'sobel');
%fprintf('Select two correspondi... |
clear all;
close all;
clc;
% Load the fitting results from 'fitBeamProfiles.m'
load fittingResults;
% Define the measurement x-axis
dt = 5; % 5 seconds between each measurement
ts = dt * [1:size(xParams, 1)]; % time axis in seconds
tm = ts / 60; % time axis in minutes
fgcol = [157 157 157]/255;
bgcol = [051 051 051]... |
function J = computeCost(y_hat,y)
m = length(y);
J = -(sum(y.*log10(y_hat+0.000001)+(1-y).*log10(1.000001-y_hat)))/m;
end |
function ss = inprod_basis(basis1, basis2, Lfdobj1, Lfdobj2, rng, wtfd)
% INPROD_BASIS Computes matrix of inner products of bases.
% If both are B-spline bases, both Lfdobj's are
% numeric, there is no wtfd argument, and the ranges are the same,
% the inner products are exact, and computed by inprod_b... |
function [tt, y_i, y_d, y_c] = flu_sim(T_y, p_y, f_y, c_y, init_y, lookback, compound, time)
if nargin < 5
init_y = 10;
end
if nargin < 6
lookback = 4;
end
if nargin < 7
compound = 4;
end
if nargin < 8
time = 150;
end
delta_time = 1/compound; % compound once a day
tt = delta_time * (0:compound*time);
... |
function visualize(fh, y, idx)
% VISUALIZE
% -----------------------------------------
% visualize(fh, y, idx, feature)
% fh: figure handle
% y: data
% idx: cluster index
% feature: which data will be shown
% Huayu Zhang, Dec 2014
figure(fh);
dim = size(y,2);
c = combnk(1:dim,2);
n = ceil(sqrt(dim));
for i = 1:size(c... |
function PDE(q)
% function PDE is to answer questions in the TP of PDE
close all; % close all figures
if nargin < 1
q = 0;
end
switch q
%% Part 1: isotropic diffusion filtering
case 1 % fix N = 30, vary lambda in [0.05; 0.3]
I = imread('img_bruit.ppm');
N = 30;
lambda = [0.05, 0.1... |
%Badanie punktu pracy
addpath ('F:\SerialCommunication'); % add a path
initSerialControl COM17 % initialise com port
Upp1=27;
Upp2=32;
n=400;
Y = zeros(2,n);
figure
for k=1:n
%% obtaining measurements
Y(:,k) = readMeasurements ([1,3]) ; % read measurements
%% processing of the measurements
disp(k);
disp ( Y(... |
function [J] = myBinary(I,T)
%
% The function binarizes the image with different thresholds,
% one for each channel.
% Use the fuction myBinary(I,T), where 'I' is the input image
% and 'T' is a 3 point vector with the thresholds for the RGB layers.
% 'T' is a vector of the form [r g b]. You can set a single value to
... |
% two sided orthogonal dictionary learning with sparse coding
function X = TSODLSC(Y, par)
% initialize D as identity matrix
T = eye(size(Y, 1));
S = eye(size(Y, 2));
f_curr = 0;
for i=1:par.Iter
f_prev = f_curr;
% update A by soft thresholding
B = T' * Y * S';
A = sign(B) .* max(abs(B) - par.Sigm... |
function [dB,dF,in,out]=sim_B(R,r,th)
% Sphere without Lorentz correction. Background is free space.
B0 = 3; % [Tesla]
% chi=0.273*4*pi; %deox blood
chi = -8e-6; % susceptibility of water
mu0 = 1.2566e-6; % permeability of free space
in=0; out=0;
if r<=R % inside
dB=(2*chi/(3+chi))*B0;
M=((3*chi)/(3+chi))*... |
function [ cbr_case ] = create_case( au_vector, label )
%CREATE_CASE Summary of this function goes here
% Detailed explanation goes here
cbr_case.au_vector = au_vector;
cbr_case.solution = label;
cbr_case.average_sim = [];
end |
function df_x = fwd_diff(f_2xr, f_xr, f_x, dx)
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
df_x = (-f_2xr + 4*f_xr - 3*f_x)/(2*dx);
end
|
% program/前期/DataSampling
% DataSamplingSVM.m
% 2015/06/02
clear all;
clc;
tic;
sample = 200;
half = sample / 2;
baseNo = sample - 2;
IndexSize = 5621;
TrainName = 'TrainPCA/%d/scores_%d_%d.xls';
TestName = 'TestPCA/%d/testscores_%d_%d.xls';
indexName = 'TrainPCA/%d/index_%d_%d.xls';
varName = 'TrainPCA/%d/variances... |
%evaluate polynomial p in respect with values array
function f = polynomialEvaluation(p,values)
f = polyval(p,values); |
%% Replication of Table 2
clear all
clc
%% Parameters
% Number of choice by each survey
M = 3;
% Number of split samples
S = 10;%[ 1 , 10 , 50 , 100 ];
% Number of observations
N = 10000;%[ 10000 , 100000 ];
% Number of Monte-Carlo repetitions
MC = 1000;
% Beta
beta = 0.5;
%% Creating distributions
% Distrubance t... |
function I = CRRmakeI3(f0,f1,p0,p1,d0,d1,M,t,polAng0,polAng1,polMag0,polMag1)
% simulation of the continuous rotating retarder light intensity. Here, we
% are able to set the polarizer angles to any value.
% I = array of light intensity values at detector
% f0 = frequency of first retarder in Hz
% f1 = frequency of se... |
%Median Filter
orginal = imread('./Image_Folder/RedFlower.jpg');
red = rgb2gray(orginal);
red=imnoise(red,'salt & pepper',0.02);
red = double(red);
red1=red;
colormap(gray(256));
figure,
imagesc(im);
axis image;
axis off;
medianKernel = [1 1 1
1 1 1
1 1 1]/8;
for i=2:size(red,1)-1
for j=2... |
% Set plot defaults
set(0,'defaultAxesTickDir','out')
set(0,'defaultAxesTickDirMode','manual')
set(0,'defaultAxesBox','off')
set(0,'DefaultFigureWindowStyle','normal') %docked or normal
set(0,'DefaultFigureColor','w')
warning('off','images:imshow:magnificationMustBeFitForDockedFigure');
% Add ImageJ to working... |
freq = [3000,2500,2000,1500,1000,800,700,600,500];
dist = [30,50,70,100,150,200,250,300];
PDR = [1 0.995884 0.98 0 0 0 0 0;
1 0.971098 0.96 0 0 0 0 0;
0.980263 1 0.925925 0 0 0 0 0;
1 0.689655 0 0 0 0 0 0;
1 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0];
marks=['+','o','*','x','<','square'];
f... |
% mctest.m
% Produce the the (~10^6 row) monte carlo table mcign for quick examination
% with plotmcvariable(s).m
% Uses static per-variable errors, except for age
%%
% Variables to include in resampled dataset
simitems={'Kv';'Latitude';'Longitude';'Elevation';'SiO2';'TiO2';'Al2O3';'Fe2O3';'Fe2O3T';'FeO';'FeOT';'MgO'... |
%
% 1-D simple example to test MAP DP clustering algorithms
%
% Free to user under the GPL licence v3.0
%
% Tested on MATLAB version 8.2.0.701 (R2013b)
%
clear all; close all;
%rng(5489,'twister'); For newer versions of matlab
rand('seed',352)
randn('seed',532)
% Model parameters
% Prior Dirichlet concentration para... |
function [shortestPath] = shortestPath(lambdak, dir, resolution, distMeasure)
%Gives minimal distance of fluid phase path from left to right (dir == 'x')
%or top to bottom (dir == 'y')
% lambdak: binary pixel input. true is exclusion, false is fluid
% distMeasure: 'cityblock' or 'quasi-euclidean', 'chessb... |
% MD = 1;
% temp = 0.46;
if MD
% DATA = DATA_md;
% FR = 49:50:2279;
else
% DATA = DATA_exp;
% FR = 300:250:18050;
end
%Lennard-Johnes
save_path = 'data\pictures\'; %path to picture
FLAG = 1;
circle_size = 5;
%% Scale coords
if MD
if ~LJ
min_x = -567;
min_... |
%% Model of Scranton & Vasseur 2016 (Theor Ecol.)
%%% Developped by Picoche & Barraquand 2018
%%% Boxplots for extant species in cases where the final result is variable
clear all; close all; clc;
thresh_min=10^(-6);
afontsize=8;
max_temp=20+273.15;
min_temp=20+273.15;
dir_output='./output_simulation/white_noise/';
... |
%% fn_structmerge
%% Syntax
% s = fn_structmerge(s,s1[,'skip|strict'][,'recursive'][,'type'])
%% Description
% set or replace values in s from those in s1, where s and s1 are
% structures of the same size
% - if 'skip', or 'strict' flag is specified: does not add new field in
% structure s (generates error if ... |
% clear;
addpath(genpath('~/github/global_tool'));
addpath('cut_face_and_area_downsample');
bu4d = dir('BU-4DFE');
bu4d = bu4d(3:end);
cou = 0;
for i_b = 1:length(bu4d)
i_b
bu4d_exp = dir([bu4d(i_b).folder filesep bu4d(i_b).name]);
bu4d_exp = bu4d_exp(3:end);
for i_e = 1:length(bu4d_exp)
i_e
... |
function Dopt = Optimize( EVs_prox,EC,Nlay,D )
%{
Optimization given Evs_prox,EC
INPUT:
EVs_prox: proxy measure for E[Vs|d] for each decision rule d
Nd x Nx matrix
EC: cost E[C|d] (exact)
Nd x Nx matrix
Nlay: # of layers for optimal evaluation (To compensate the loss of solutions by w... |
function [pHat,out_param]=meanMCBer_g(varargin)
%MEANMCBER_G Monte Carlo method to estimate the mean of a Bernoulli random
%variable to within a specified absolute error tolerance with guaranteed
%confidence level 1-alpha.
%
% pHat = MEANMCBER_G(Yrand) estimates the mean of a Bernoulli random
% variable Y to within... |
% problem 1
a = 10;
b = 2.5e23;
c = 2 + 3*i;
d = exp(j*(2*pi/3));
% problem 2
aVec = [3.14 15 9 26];
bVec = [2.71;8;28;182];
cVec = 5:-0.2:-5;
dVec = logspace(0,1,101);
eVec = 'Hello';
% problem 3
aMat = 2*ones(9);
v = [ 1 2 3 4 5 4 3 2 1];
bMat = diag(v);
u = 1:100;
cMat = reshape(u,10,10);
dMat = nan(3,4);
eMat = [... |
function difdiv1=fdifdiv(n,x,y)
%diferencas divididas em todo i
k = 1; %diferenças de 1ª ordem
for i = 1:n
difdiv(i,1)= (y(i+1)-y(i))/(x(i+1)-x(i));
end
for k = 2:n %diferenças de kª ordem
for i = 1:n+1-k
difdiv(i,k) = (difdiv(i+1,k-1) - difdiv(i,k-1))/(x(i+k)-x(i));
end
end
% difdiv % variável matric... |
fileLeap = strcat('plotLeapfrog.dat');
fidLeap = fopen(fileLeap);
Plot_File = fscanf(fidLeap,'%g',[20 3]).';
fclose(fidLeap);
simID = 2;
nbParticles = 300;
nbSteps = 11;
fileRad = strcat('radial_after_',num2str(simID),'_leapfrog.dat');
fidRad = fopen(fileRad);
Rad_File = fscanf(fidRad,'%g',[3 nbSteps]).';
fclose(fidRa... |
% Read in synthetic data created in python
M = csvread('../data/python_synthetic.csv');
trans_ = [0.6,0.4;
0,1];
emis_ = [0.6, 0.4;
0.4, 0.6];
[estTR,estE] = hmmtrain(M,trans_,emis_)
|
%% BME 790.01F13 Engineering Programming and Signal Processing
%% Worksheet 6 Kanishk Asthana ka112@duke.edu
clear;
clf;
%Defining time step for input signal
dt=0.001;
%Defining fundamental time period as 10pi
T=10*pi;
%Input signal goes from -T/2 to T/2;
t=-1*T/2:dt:T/2;
input=zeros(1,length(t));
input(t>=-1*T/8 & t<... |
function [x_kk] = normalize_pixel_1(xn,fc,cc,kc,alpha_c)
%% The revarse function of normalize_pixel
%normalize
%
%[xn] = normalize_pixel(x_kk,fc,cc,kc,alpha_c)
%
%Computes the normalized coordinates xn given the pixel coordinates x_kk
%and the intrinsic camera parameters fc, cc and kc.
%
%INPUT: x_kk: Feature locations... |
function [Out,est,vector_mlsd_int]=criterio(camino_1,camino_2,fft_out,HL_est,pos,cam_1,cam_2,data_mlsd_1,data_mlsd_2,vector_mlsd,vector_mlsd_int)
% Evaluate the two possible paths FROM where that state can be reached.
% And calculates which path is more likely, this is done with the criteria
%of the MLSD (Maximum... |
function [] = BatchRunSimulations(results_folder,data_location,varargin)
addpath('Models/ModelBase')
addpath('Models/ClosedLoopModel/ClosedLoop')
addpath('Models/ClosedLoopModel/SimulationCreation')
addpath('Libraries/Utils')
Nruns = 3;
nCells = 10000;
Nsteps = 600;
prerun = 180;
bandwidth = 14;
opt = input... |
function[areaMatrix] = removing_cells(areaMatrix, removedCells)
col = size(areaMatrix,2);
line = size(areaMatrix,1);
while removedCells > 0
areaMatrix(line,col) = -1;
line = line - 1;
removedCells = removedCells - 1;
if line == 0
line = s... |
function varargout = libFindFigure(tag)
% Return the handle of a figure with the given tag. If no figure exists,
% then make a new figure and set its tag.
h_fig = findobj(0, 'type', 'figure', 'tag', tag);
if isempty(h_fig) || not(ishandle(h_fig))
h_fig = figure('position', [20 80 1000 580]);
set(h_f... |
%% input data
user22final = removevars(user22finalfile,{'VarName1'});
gt = user22final(:,{'groundtruth'});
array = table2array(gt);
gt_new = cellstr(array);
gt_class_labels = grp2idx(gt_new);
user22final = removevars(user22final,{'groundtruth'});
user22final = table2array(user22final);
user22final = transpose(user22fin... |
function [compl_indexes,compl_indexes2] = PACK_recompute_complexity_indexes(archs,results)
global params
r = global_jess_engine();
instr_list = params.packaging_instrument_list;
narc = size(archs,1);
compl_indexes = zeros(narc,1);
compl_indexes2 = zeros(narc,1);
for i = 1:narc
fprintf('Recomputing complexity factor... |
%Загружаем значения и обрезаем значения
x = x_value2;
y = y_value2;
x_new = [];
y_new = [];
for k=1:250
if x(k)>0
x_new=[x_new x(k)];
y_new=[y_new y(k)];
end
end
x = x_new;
y = y_new;
figure(3)
% y = (y - mean(y))/std(y)/2;
% x = (x - mean(x))/std(x)/2;
plot(x,y,'.')
hold on
start_point = 0;... |
function [asm] = I_Assembly2Assembly(app,i_asm,classifyFlag)
% I_Assembly2Assembly restructures imported I_Assembly
% Removes empty I_Parts
% combines I_Parts with one I_Solid to Component
% Converts I_Parts with multiple I_Solids to Assembly
% Assigns features to Components
h = waitbar(20,['convert ass... |
function [S, C_out] = FA(A, B, C_in)
s1= xor(A,B) ;
S= xor(C_in,s1) ;
C_out = or (and(A,B) , and(C_in,s1)) ;
end |
function [vicon_time, vicon_readings, acc_time, acc_readings] = load_nri(dir, model)
[R, unR, H, unH] = utils;
% sanity checks
vicon_filename = [dir '/vicon.csv'];
acc_filename = [dir '/stb.acc.csv'];
if ~exist(vicon_filename, 'file')
error('no vicon.csv in that directory');
elsei... |
function pac_segment(subj,block)
if ~strcmp(block(1:3),'Day') && ~strcmp(block(1:3),'All') && ~iscell(block)
block = {block};
else
if strcmp(block(1:3),'Day')
anadir = anadir_day;
if ~exist(anadir)
mkdir(anadir)
end
elseif strcmp(block(1:3),'All')
... |
function filter_bank_analysis3(Hz,theta,fs,n,trig,rt,chan2use,options,IDX_Hz,filters,timeE,epoch,shiftperiod,experiment,direct)
startTime = tic;
%% ----- settings for five second epoch
limit2 = [0 5]; % zero-padding for FFT and determining the best electrodes!
n2 = [];
[n2, ~, ~, f2, IDX_Hz2, ~ ] = freqsettings( Hz,... |
clear all;
clc;
f1 = @(t, y, z) z;
f2 = @(t, y, z) 2*z - 2*y + exp(2*t)*sin(t);
% Taking inputs
fprintf('Input initial Condition on y:\n');
t(1) = input('t0: ');
y(1) = input('y0: ');
fprintf("Input condition on y'(condition on derivative)\n");
derOfX = input('t0: ');
derOfY = input('y~: ');
z(1) = derOf... |
classdef Modelblink
%MODELBLINK Summary of this class goes here
% Detailed explanation goes here
properties
AverageOn
AverageOff
VarianceOn
VarianceOff
end
methods
%no functions
function obj = Modelblink()
end
funct... |
% Uncomment the lines below on first run to load data, comment after to
% prevent long reloading
disp('Loading data')
M = importdata('out/matches_raw_heroes.csv');
[N, p] = size(M.data);
disp('Splitting data')
trainN = ceil(0.9 * N);
testN = N - trainN;
ii = randperm(N);
trainY = M.data(ii(1:trainN), 2);
trainX = M.d... |
function CC = get_cc(stn1_s,stn2_s,t_bin_ms,t_w_ms)
%This was the way that Kerry proposed to run the correlations. I don't
%think this is correct
num_spikes_n1 = length(stn1_s);
t_ms = [-t_w_ms:t_bin_ms:t_w_ms];
stn1_ms = stn1_s.*1000;
stn2_ms = stn2_s.*1000;
cc_psth = zeros(num_spikes_n1,numel(t_ms));
for spike = 1:... |
function lon = wrap180(lon)
%
% Written By: Michael Hutchins
q = (lon < -180) | (180 < lon);
a=lon(q)+180;
positiveInput=(a>0);
a=mod(a,360);
a((a==0) & positiveInput)=360;
lon(q) = a - 180;
|
function overall_exit_status = check_termination(soc_pct,v_cell,params)
% Copyright (c) 2018 Gopalakrishnan, Krishnakumar <krishnak@vt.edu>
% Author: Gopalakrishnan, Krishnakumar <krishnak@vt.edu>
exit_status = 0; % No abnormal condition has been reached. Simulation valid.
if soc_pct < params.CutoffSOC
fprintf('... |
%% Version 1.0
%% Implementation of Robot Path Planning using Probabilistic Roadmap Method with Randomized Bridge Builder as described in [Hsu et al., 2013]
%% Created by Jose Barreiros, PhD student, Systems Engineering, Cornell University.
delete(findall(0,'Type','figure')) %clean figures
% Import Image
filepath ... |
% Script to read in retrieved VCD data and format them appropriately to
% create the NDACC HDF files
% Created by Kristof Bognar, 2017
%
% Code saves bash script that can be run on berg (to create HDF files in IDL)
%
% Runs for specified instrument/tracegas
%
% Creates either monthly or yearly HDF files
%
% GBS VCDs ar... |
function model = initializeModel()
%
% This function returns the model (parameters) for ranger's physics and
% controller simulation.
model.control.ank.qSpring = 0.0;
model.control.ank.kSpring = 0.0;
model.control.ank.kMotor = 0.612;
model.control.ank.uMax = 3.6; %3.6 Nm continuous, 4.8 Nm peak
model.control.hip.qSp... |
fn = fieldnames(bs_new);
for i = 1:length(fn)
disp(fn{i});
% sum(bs.xxx == bs_ori.xxx)
% eval( ['sum(bs.' fn{i} '==bs_ori.' fn{i} ')' ] );
eval( ['a = bs_new.' fn{i} ';'] );
eval( ['aa = bs_ori.' fn{i} ';'] );
len = length(aa);
a = a(end-len+1:end);
try
s = sum(a ==... |
%% Pick training data samples from HSI data cube and ground truth.
% This script is for 1D CNN training only. The datacube is transformed into
% 4-D array as an input data set for the CNN while labels will be made as
% categorical vectors.
seg_image = rgb_from_corrected; % zeros(cols, lines, 3, 'uint8');
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.