text stringlengths 8 6.12M |
|---|
classdef fourierTools < handle
% Tools facility for Fourier calculation
methods (Static)
function out = fftCorrel(x,y)
nPts = length(x(:));
out = ifft2(fft2(x).*conj(fft2(y)))./nPts;
end
function out = rolledFFT(x)
nPts = le... |
% clear; close all; clc
addpath('Ex 24');
addpath('Ex 24/minFunc');
%% generate data
% need:
% m1TrainData
% m2TrainData
% m1TestData
% m2TestData
% trainTargets
% testTargets
n = 100000;
resz = [50,50];
% nq0 = 50000;
% nq1 = 50000;
% %[dataset1,dataset2,x,y,z,~,~] = get2data(n,str,resz);
% [dataset1,dataset2,x,y... |
% ADVISOR data file: GC_PM63.m
%
% Data source:
% D. Bauch-Banetzky, et al., "Permanent magneterregte Synchronmaschine mit Nd-Fe-B
% Dauermagneten für den Einsatz in Personenkraftfahrzeugen"
% published in "VDI (Verein Deutscher Ingenieure) Berichte 1459:
% Entwicklung Konstruktion Vertrieb HYBRIDANTRIEBE"
% VDI Ver... |
%
% Sript to test code
%
clear all
clc
%create modulator:
freq1=10e6;
mod1=cw(freq1);
mod1(1:1:10)/5000
lkpl
freq2=2.5e6;
mod2=cw(freq2);
mod=mod1+mod2;
%mod=5000*[1, zeros(1, 99999)];
%mod=[1 j]*randn(2, 100000);
%QPSK constellation
n_bits=100000;
Q=8;
pulse_shape = ones(1, Q);
%Random bits
%b = ... |
function ypredicted = linear_model_1_predict(points,theta)
%LINEAR_MODEL_1_PREDICT Summary of this function goes here
% Detailed explanation goes here
points = [points;points.^2; points.^3;sin(points)];
ypredicted =[ones(1,size(points,2));points]' *theta;
end
|
pkg load symbolic;
clc;
clear all;
syms x;
eqn = 6 * x^5 - 41 * x^4 + 97 * x^3 - 97 * x^2 + 41 * x - 6 == 0;
S = solve(eqn);
ans = double(S);
ans
|
data=dlmread('fashion57_train.txt');
label=[ones(32,1);2*ones(28,1)];
%h
num=4;
h1=round(32*rand(num,1));
h2=round(28*rand(num,1))+33;
data=[data(h1,:);data(h2,:)];
label=[label(h1,:);label(h2,:)];
traindata=prdataset(data,label);
% D = (1/60)*ones(60,1);
% [error, beta,weight, ret]=adaBoost(traindata,D,3... |
%% Heat Budget Stuff
% The data:
cd /noc/altix/scratch/hb1g13/MITgcm/nchannel/Heat_Bugets
fname='Heat.nc';
fname2='Heat_Surface.nc';
Tend=ncread(fname,'TOTTTEND'); %X,Y,Z (degc/day)
Avx1=ncread(fname,'ADVx_TH'); %Xp1,Y,Z (degC.m^3/s)
Avy1=ncread(fname,'ADVy_TH'); %X,Yp1,Z (degC.m^3/s)
AVz=ncread(fname,'ADVr_TH'); %X,Y,... |
load([project.paths.processedData '/processed_data_word_level.mat'],'D');
time_window = [-0.5 0.5]; %[-0.2 0.6]
timeStep = 25;
cond = {'speech','listen'};
subcond = {'PreSpeech','PostListen','PresListen'};
%% preprocess and clean
eeg_data = [];
for sub = 16:length(project.subjects.list)
partner = project.s... |
function RESP = analyze(X)
if nnz(X)>0
RESP = vdoc_as_opt('visdoc',X);
else
RESP=1;
end
return |
classdef SparseFiltering < handle & Learner
%sparse filtering wrapper
properties
weights; %feadim*numunits
numunits;
type; %activation type
DC_remove = true;
max_iter_per_batch = 300;
batch_size;
... |
fileID = fopen('log.txt','r');
points=textscan(fileID,'%f %f %f','Delimiter',' ');
size(points{2})
r=sqrt(points{1}(1)^2+points{2}(1)^2+points{3}(1)^2)
plot3(points{1}(1:end),points{2}(1:end),points{3}(1:end),'*');
hold on;
t=linspace(0,pi,25);
p=linspace(0,2*pi,25);
[theta,phi]=meshgrid(t,p);
x=sin(theta).*sin(phi... |
% Atahan Kurttiži
% ANN-ML Homework #1.2
% Multi-Layer Back Propagation
maxiteration=200;
n=1; % Learning Rate
z=0;
n_hid=3; % Number of hidden layers
n_out=2; % Number of outputs
n_input=3; % Number of inputs
w_hid=rand(n_input,n_hid); % Randomized weights for hidden layers
w_out=rand(n_hid,n_out); % Ra... |
function obj = RunBayesDecoderJackknife(obj, varname, predictorname, varargin)
if nargin < 4
%dialog to ask for training and test sets
if numel(obj.SubsetVal.contrast) > 1
[contsel,ok] = listdlg('ListString',strsplit(num2str(obj.SubsetVal.contrast)), 'Name', 'Contrast for training', 'InitialValue', 2);
... |
function crv=nrbrefine(crv,nctrlptsins,regularity)
[~,~,new_knots]=kntrefine(crv.knots,nctrlptsins,crv.order-1,regularity);
% disp('ik')
% disp(new_knots)
crv = nrbkntins (crv , new_knots);
end |
function [flag,a_list] = value_function3( range,range_rate,v )
global v_label;
global a_possi_table;
a_label = -4:0.2:2;
flag = 1;
test_num = 300;
dt = 0.1;
state = [range,range_rate,v];
a_list = zeros(1,300);
for i = 1:test_num
v_num = find_num(state(3),v_label);
a_possi_list = a_possi_table(v_num,:);
[a_t... |
%simulateData function
function [data,nv,N,m]=simulateData
prompt = 'What is the seed for random generator(e.g. 1)? ';
seed = input(prompt)
rng(seed);
prompt = 'What is the number of views? ';
nv = input(prompt)
prompt = 'What is the number of subjects in the population? ';
N = input(prompt)
prompt = '... |
% edited verson of first coding by Prof. Martin
clear;clc;
%%
%generate the matrix(elements are between 0 and 1)
n = 30;
count=0; % count the # of permutations found with smaller function value
rng('default');
G = rand(n,2*n);
A = G*G';
A = A - floor(A);
A = max(A,eye(n)); % matrix A
p = linspace... |
function [Parameters, Labels] = createData(Scan)
i = 1;
for imageIndex= 1:1521
if( mod(imageIndex,100) == 0)
fprintf('%d\n', imageIndex);
end
%ejemplos positivos
lx = Scan(imageIndex).lx; ly = Scan(imageIndex).ly;
rx = Scan(imageIndex).rx; ry = Scan(imageI... |
% ADVISOR Data file: FC_CI246.M
%
% Data source: Cummins Engine Company published spec sheets
%
% Data confidence level: no comparison has been performed
%
% Notes: Data provided included, mass, max torque vs. spd, and fuel consumption @ full load vs. spd.
% All other information has been estimated!!
%
% Created on... |
train_y=TrainingSet(:,1);
train_x=TrainingSet(:,2:end);
test_y=TestingSet(:,1);
test_x=TestingSet(:,2:end);
Method_option.plotOriginal = 1;
Method_option.xscale = 0;
Method_option.yscale = 0;
Method_option.plotScale = 0;
Method_option.pca = 0;
Method_option.type = 1;
[predict_Y,mse,r] = SVR(tra... |
%% Location-dependent Frequency Response
% Created on 05/17/2018
%--------------------------------------------------------------------------
Data_Path = 'Data';
Measure_Freq = [20,50,100,200,250,300,500];
data_num = length(Measure_Freq);
Measure_Type = sprintfc('%03dHz_sine',Measure_Freq);
acc_ind = setdiff(1:46,[10,2... |
function [ Ycap ] = lraNCP( Y,opts )
%% Fast Non-Negative CP Decomposition based on Low-rank Approximation
% Usage: Ycap=lraNCP(Y,opts);
% Input: Y can be ktensor/ttensor/tensor/double
% Output: Ycap is a nonnegative ktensor
%
% Parameters:
% opts.NumOfComp: rank of Ycap
% opts.lra_model: [CP]|Tucker|none -... |
function theta0theta1
close all;
fig1 = figure;
set(fig1, 'Position', [412 313 915 632]);
load AlDataVoce.dat
dat = AlDataVoce;
theta0 = dat(:,1);
theta1 = dat(:,2);
T0 = dat(:,3);
plot(T0, theta0, 'rs', 'LineWidth', 2, 'MarkerSize', 10);hold on;
[C,S] = polyfit(T0,theta0,1);
xmin = 70;
xmax = max(T... |
function [ H1, H2 ] = computeH1H2( F )
[V,D] = eig(F);
% i = (diag(D) >= -0.001) & (diag(D) <= 0.001); %original
i = abs(diag(D)) == min(abs(diag(D))); %jk
e0 = V(:,i);
[V,D] = eig(F');
% i = (diag(D) >= -0.001) & (diag(D) <= 0.001); %original
i = abs(diag(D)) == min(abs(diag(D))); %jk
e1 = V(:,i);
d0 = [0;e0(1);0];... |
function params = learnParameters(pathNewTrainingFolder,dir_root)
%learns the parameters of the objectness function: theta_MS (for 5 scales),
%theta_CC, theta_ED, theta_SS and also the likelihoods corresp to each cue
%dir_root - path where the software is installed - see README Setting things up
if nargin < 2
dir_... |
function [preL, nRejected] = generatePreLearningActivity(perturbedMapping, LI_stats, LP_clouds, nPerCloud, ENSURE_PHYSIOLOGICAL_PLAUSIBILITY)
% @ Matt Golub, 2018.
numConditions = numel(LP_clouds.cursorToTargetDirection);
%% Find average cursor-to-target direction for each condition
% This will be used instead of tim... |
data1 = load('data.mat')
clc
F1 = data1.F1
F2 = data1.F2
% Form the train and test data
F1_train = F1(1:100,:);
F2_train = F2(1:100,:);
F1_test = F1(101:1000,:);
F2_test = F2(101:1000,:);
% Define mean and standeviation matrices
means_F1 = zeros(1,5);
std_dev_F1 = zeros(1, 5);
means_F2 = zeros(1,5);
std_dev_F2 = zero... |
function [ProcPwr data] = ibuildmodel(bm,varargin)
% buildsp - builds the data spreadsheet for a benchmark
numvarargs = length(varargin);
if (numvarargs > 2)
error('ibuildmodel: too many optional arguments');
end
optargs = {0 0};
if (numvarargs > 0)
optargs(1:numvarargs) = varargin;... |
function checkFileUsage()
global data
sensors=fieldnames(data);
nSensors=length(sensors);
fileNamesStack={};
for i=1:nSensors
fileNamesStack=cat(1,fileNamesStack,data.(sensors{i}).metadata.files.names{1});
end
fileNamesStack=unique(fileNamesStack);
[currentYear,~,~]=datevec(now);
startYear=2008;
season_names = ... |
function [vals,xvals] = getFunctionValues(cf,varargin)
%REFRACTORY/getFunctionValues - Return recovery function values
% [VALS,XVALS] = getFunctionValues(CF,VARARGIN) returns the
% values of the recovery function in VALS and the corresponding
% time values in XVALS. CF is a curve fit object returned by the
% ... |
clear all;close all;clc;
load ts_non_uni.mat
part.ts.trans_array_enable()
[Win, Cwin, cont_non] = part.ts.win_primal([], B, [], 'exists', 'forall', []);
save cont_non.mat
|
classdef voltMeter < qes.hwdriver.sync.instrument
% dc voltage meter
% Copyright 2017 Yulin Wu, USTC, China
% mail4ywu@gmail.com/mail4ywu@icloud.com
methods (Access = private)
function obj = voltMeter(name,interfaceobj,drivertype)
if isempty(interfaceobj)
error('voltMeter:In... |
% created: Zoya Bylinskii, Aug 2014
% Code for computing degrees of visual angle
% This code has been written to make it easier to report visual angle in
% papers, and to ensure a standardized calculation is used.
% This code can take variable input (e.g. horizontal, vertical, or diagonal
% screen measurements in any... |
function [x1,delta] = api_51(g, x0, eps)
delta=eps+1;
loops=0;
while(delta>eps)
x1=g(x0);
x0=x1;
delta=abs(x1-g(x1));
loops++;
end
loops
end
|
function b=bpp(qnz,n,Q)
S=0;
for c = 1:3
for j = 1:n:size(qnz,1)-(n-1)%n denotes block size
for k = 1:n:size(qnz,2)
n_qnz = qnz(j:j+(n-1),k:k+(n-1),c);
[NZ,IDX,AS,dc]=adaptive_scan(n_qnz); %doing for types of scan in each block
[E,B]=encode(Q,n,NZ,IDX,AS,d... |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This code demonstrates a simple implementaion of 6 numerical schemes
% to solve the unstead 1D Euler equations.
%
% This code can be directly applied to study a 1D shock-tube problem just
% by imposing a jump intial conditions in the middle of the domai... |
% Dijkstra算法
% 作者:Ally
% 日期:2021/1/1
clc
clear
close all
%% 阶段-状态定义
stages = 5;
nodes_dist = cell(stages-1,3);
% 第1阶段
nodes_dist{1,1} = 1;
nodes_dist{1,2} = [1,2,3];
nodes_dist{1,3} = [2,5,1];
% 第2阶段
nodes_dist{2,1} = [1;2;3];
nodes_dist{2,2} = [1,2,3];
nodes_dist{2,3} = [12, 14, 10; 6, 10, 4; 13, 12, 11];
% 第3阶段
n... |
numAzElements = 8;
numElElements = 4;
MinY = -90;
MinX = -90;
MaxY = 90;
MaxX = 90;
% % %----------------------------------------
% % % aqcuire device, set rate, and add channels
% % %
% % %----------------------------------------
% % devices = daq.getDevices;
% % s = daq.createSession(devices.Vendor.ID);
% % %set ... |
function [net_ssim, mean_ssim] = cal_ssim(net,ref_imgs,input_imgs)
% calculate Structural Similarity Index (SSIM) of the network
%
% Return:
% net_ssim : cell
% SSIM of each images in noisy_imds
% mean_ssim : numeric
% mean SSIM
%
% Parameters:
% net (Required) : Serial network
% networ... |
function plotGtKvMvCombined(imgGt, imgKv, imgMv, imgCombined, initialWindow, mainTitle, transpose)
% Copyright (c) 2011 by Andreas Keil, Stanford University.
%% Check Input Arguments
if nargin < 7
transpose = true;
elseif ~isscalar(transpose) || ~islogical(transpose)
error('If specified, "transpose" has to be eith... |
function [tableau, basis] = makeTableau(c,A,b)
n = length(A);
[nr,nc] = size(A);
tableau = zeros(nr+1,length(c)+nr+1);
r1 = [-c',zeros(1,nr+1)];
tableau(1,:) = r1(:)';
tableau(2:nr+1,1:nc)=A;
tableau(2:nr+1,nc+1:size(c)+nr)=eye(nr);
basis = (nc+1:size(c)+nr)';
tableau(2:nr+1, length(c)+nr+1) = b;
end |
% Computes the coefficients vector of a polynomial regression with n examples and m features per example.
% The features are combined to create higher order features up to a provided degree.
% The examples are divided into two sets, one for training and one for testing.
% @param X the matrix with the feature values of ... |
time = [InvivoMean.Time];
ydata = [InvivoMean.Mean];
tbl = table(time,ydata)
modelconc = @(b,x) 1220.*(exp((-b(1).*x(:,1)))- exp((-b(2).*x(:,1))));
beta0 = [0,10]
mdl = fitnlm(tbl,modelconc,beta0)
|
function [AA,BB,CC,DD,Gs,Go,Gi,dims] = dscb(A,B,C,D,tol)
%DSCB Special Coordinate Basis for Discrete-time Systems
%
% [As,Bt,Ct,Dt,Gms,Gmo,Gmi,dim] = dscb(A,B,C,D)
%
% decomposes a discrete-time system characterized by (A,B,C,D)
% into the standard SCB form with state subspaces x_a being
% ... |
% SetBorderColor - This will set the color of the border box.
% Viewer.SetBorderColor(color)
% Color - This should be three doubles between [0,1] that represent (r,g,b) of the desired background color.
function SetBorderColor(color)
D3d.Viewer.Mex('SetBorderColor',color);
end
|
classdef EllipticProblemInVertical3d < SWEBarotropic3d
%> Note: This solver is used for test purpose of operator
%> $$\nabla\cdot\mathbf{K}\nabla p=f$$. Here, $\mathbf {K}$ is
%> positive definite, and is given by,
%> $$\mathbf K = \left [\begin{matrix}1&&0&&k_{13}\\0&&1&&k_{23}\\
%> k_{31}&&k_... |
function w = Levbg_Maqdt_alg(x,y)
m = height(y);
lemda_k = 1;
lemda = 1;
vec_w = zeros(10,16);
vec_l = zeros(10,30);
vec_l_one = zeros(1,30);
for j = 1:10%multiple run
%initialize w,lemda
for i = 1:16
w(1,i) = 0.1*rand();
end
fi = get_resi(x,y,w);
l_w_norm = norm(fi)^2 + lemda*(norm(w))^2;
i = 0;
%... |
function uF = SolvDDschur(Sys)
SF = Sys.AFF*0;
for ir=1:length(Sys.RegDoF)
fprintf('%g\n',length(Sys.AII{ir}));
tic
SF = SF - Sys.AFI{ir}*(Sys.AII{ir}\Sys.AIF{ir});
toc
end
tic
SF = SF+Sys.AFF;
uF = SF\Sys.gF;
toc
end |
function lh=plotBehaveHist(t, behave, toneTime, eventNames)
leg = {};
for event_i = 1:length(eventNames)
if all(behave(event_i, :)==0)
continue;
end
leg{end+1} = eventNames{event_i};
switch eventNames{event_i}
case 'lift'
plot(t, behave(event_i, :), 'b','LineWidth',3);
... |
classdef TPA_ManageEventAutodetect
% TPA_ManageRoiAutodetect - finds intersting events in the Behavioral data
% Inputs:
% none
% Outputs:
% strEvent - event descriptions
%-----------------------------
% Ver Date Who Descr
%-----------------------------
% 19.06 2... |
function BodyR = BodyR(s1,phi1,theta,s2,phi2,x1,y1,g,k1,k2,L_sp0,L_mB,mB,IB,m2)
%BODYR
% BODYR = BODYR(S1,PHI1,THETA,S2,PHI2,X1,Y1,G,K1,K2,L_SP0,L_MB,MB,IB,M2)
% This function was generated by the Symbolic Math Toolbox version 7.1.
% 14-Jan-2017 01:29:06
t2 = phi1-theta;
BodyR = [x1+L_mB.*cos(t2)-s1.*sin(phi... |
function [tInd,eInd] = crossvalind(method,N,varargin)
%CROSSVALIND generates cross-validation indices
% each time.
%
% [TRAIN,TEST] = CROSSVALIND('HoldOut',N,P) returns logical index vectors
%
% [TRAIN,TEST] = CROSSVALIND('LeaveMOut',N,M), where M is an integer,
% returns logical index vectors for cross-validation of N... |
function [x0, x1, cx] = ENO_Interpolation_Setup(N0, N5, Order, x, dx)
x0 = x(N0);
x1 = x(N5);
cx = zeros(1,Order+1);
for n = 1:Order+1
cx(n) = (n-1) * dx;
end |
function [simulations,fatesmatrix,errorcatched,paramcatched] = VTD_Landscape_Model_Pred_v1_AbsDistance_Gauss_Fates_PreSim(t0,dt,t1,times,samples,InitialCondition,nsimulations,paramsimulations,NoiseX,NoiseY,mutantstofit,nmutants,NumClust,Initial,OldData)
errorcatched = 0;
paramcatched = [];
simulations = zeros(2,times... |
function [EvaluationMatrix] = SVM_Classifier_Test(data)
% This function tests a created SVM classifier using the saved classifier
% object and the user inputted test 'data'. It uses the model to classify
% every image within the data and produces an 'Evaluation Matrix' to show
% the results. It is of the form:
%
... |
%AW: See comments on problem 2 below. 0.89/1.
%Inclass assignment 5.
% 1. (a) Write a function that reads in an image and displays it so that 1%
% of the pixels are black and 1% of the pixels are white. Hint: your
% function can call the stretchlim function, see the help for that function.
% (b) Write a second funct... |
clear all;
close all;
anno_files = './Annotations_Part/%s.mat';
examples_path = './Result';
examples_imgs = dir([examples_path, '/', '*.jpg']);
cmap = VOClabelcolormap();
pimap = part2ind(); % part index mapping
countPeople=0;
IM=0;
for ii = 1:numel(examples_imgs)
ii
imname = examples_imgs(ii).name;
... |
function y = SoftCastEncoder(dctcoeff,P,rejectMatrix,chunkVarVec,chunkSize)
if ~exist('P','var')
P = 1;
end
if ~exist('chunkSize','var')
chunkSize = [10 10];
end
numOfComp = size(dctcoeff,3);
numOfFrames = size(dctcoeff,4);
y = {};
for iFrame = 1 : numOfFrames
for iComp = 1 : numOfComp ... |
clear;close all;clc;
train = '.\trainingROI\';
nFiles = dir(train);
for i = 1:length(nFiles)
if( ~strncmp( nFiles(i).name,'.',1 ) )
folderName = nFiles(i).name;
nFiles2 = dir( [train,folderName] );
K = 250 * 250; % rows
N = length(nFiles2) - 2; % columns
... |
function opts = mkopts_csb(T);
opts.algorithm = 'csb';
opts.use_kd_tree = 0;
opts.initial_K = T;
opts.do_greedy = 0;
opts.do_split = 0;
opts.do_merge = 0;
opts.do_sort = 0;
% Local Variables: ***
% mode: matlab ***
% End: ***
|
function [d, d_a, blocks_RGB]=verifier(image_t, F_E, K, Gs1, Gs2, Tr_a,f_tform)
%% Step (1)
% Decrypting
F_D=decrypt(F_E, K);
image_t = single(image_t);
%% Step (2)
% Key point-based features extraction from image_t
F_t=cell(1,5);
F_t{4}=F_D{4};
F_t{5}=F_D{5};
if strcmp(f_tform, 'SURF')
% Detect the SURF... |
% e)
R = 100000;
S = 10000;
p = 24;
lambda = 100000/24;
fname = 'movies.txt';
alfa=0.1;
n = 6;
W = 0;
while 1
for n=5:6
for W=0:10
% Run simulators
[blocking_hd, blocking_4k] = simulator2(lambda,p,n,S,W,R,fname);
[blocking_hd_2, blocking_4k_2] = simulator2(lambda,p,n-1... |
function [TradeDate, OpenofStock, HighofStock, LowofStock, CloseofStock] = GetAndMergeMarketData(stkcdlist, startdate, enddate)
%GetAndMergeMarketData 从wind上获取数据
% 创建日期: 2019年3月3日
% 调用数据提取函数,提取股票行情数据和因子值
% 输入: 股票列表,起止日期
% 输出: 交易日,以及每个交易日的OHLC
end
|
%% Opdracht 3
% Maak een functie genaamd 'opdracht_3' om de verhouding van de langste en
% kortste beenlengte te berekenen.
%
% Je moet de verhouding (ratio) bepalen
% van de grootste beenlengte en de kleinste beenlengte. Deze beenlengte
% zitten in de input variabele genaamd: 'beenlengtes'.
% 1 - Bepaal m.b.v. een s... |
a=50;
b=-50;
k=0;
f = @(x) 1-x+sin(x);
while abs(b-a)>10^-4 % use while loop
fa=f(a); %*
fb=f(b); %*
if(fa*fb<0)
al=a;
c= interp1([a,fa],[b,fb],0);
br=b;
fal=f(al); %*
fc=f(c); %*
fbr=f(br); %*
if(fal*fc<0)
a=al;
b=c;
end
if(fc*fbr<0)
... |
function[ o ] = ObjectiveFunction( x )
% List your constraints
%const1 = x(2)<= 2.2||x(2)>=5.4;
%const2 = (x(1)/2 + x(2)^2)>= 1;
%const3 = x(1)~=x(2);
%if const1 == 1 && const2 == 1 && const3==1
o = sum(x.^2);% Osphere test function
%else
%the solution is not feasible(infeasible)
%o = sum(x.^2)... |
k_size = 20;
i_size = 2;
j_size = 2;
generations = 10000;
H = zeros();
H_evol = zeros(i_size,j_size,k_size);
X{1} = x1;
X{2} = x2;
p1 = zeros();
p2 = zeros();
% u = H*x
for k=1:k_size
for i=1:i_size
for j=1:j_size
H(i,j,k) = rand();
end
end
end
for g... |
function FImaker(startpath,figurepath,indices,folders,legendnames)
Erate = zeros(length(folders),21);
Irate = zeros(length(folders),21);
Epeakwidth = zeros(length(folders),21);
Ipeakwidth = zeros(length(folders),21);
Epeakheight = zeros(length(folders),21);
Ipeakheight = zeros(length(folders),21);
EndSpikes = nan(l... |
%-----------------------------------
% Problem 3
%-----------------------------------
figure;
x = -100:100;
subplot(4,2,1);
y1 = sin(x);
plot(x,y1);
title('Problem 3: sin(x)')
subplot(4,2,2);
y2 = sin(50.*x);
plot(x,y2);
title('sin(50*x)')
subplot(4,2,3);
y3 = 50.*sin(x);
plot(x,y3);
title('50*sin(x)')
subplot(4,2... |
function J = faceAlign(img_fn, P,staKey)
imageSize = 160;
I = imread(img_fn);
if ndims(I) == 3
I = rgb2gray(I);
end
PM = staKey;%the standard face image keypoint
tform = cp2tform(reshape(P, 2, [])', reshape(PM, 2, [])', 'affine');
invT = tform.tdata.Tinv;
xy = [repmat([1:160],1,160);reshape(repmat([1:16... |
% Plot degradation comparisons
load('Fit2K_Filtrate_AFG2_RpyrAll_glucose.mat')
TRpG = T;
DRpG = D;
DERpG = DE;
load('Fit2K_Filtrate_AFG2_ReryAll_glucose.mat')
TReG = T;
DReG = D;
DEReG = DE;
load('Fit2K_Filtrate_AFG2_RpyrAll_starch.mat')
TRpS = T;
DRpS = D;
DERpS = DE;
load('Fit2K_Filtrate_AFG2_Rer... |
% main program main_practice_test2
% a. graph the function on [-5,5]
x=[-5:0.1:5];
for i=1:101
f(i)=practice_test(x(i));
end
plot(x,f)
% b. calculate its roots
root=fzero(@(x) practice_test(x), 3)
% c. calculate intagral -4 to 4 of f(x)dx
integral=quad(@(x) practice_test(x),-4,4)
|
function G = add_edge(G,node_from_id,node_to_id,edge_weight)
% add_edge(G, ID1, ID2, weight) adds a directional, weighted edge
% from G.V(ID1) to G.V(ID2).
if (node_from_id == node_to_id)
warning('Self-referencing edge being added to graph.');
end
if (edge_weight <= 0)
warning(['Illegal weight (' num2s... |
function t = aliSmoEnaki(v)
%ALISMOENAKI Summary of this function goes here
% Detailed explanation goes here
t = 0;
n = length(v);
for i=1:n
for j=i+1:n
if v(i) == v(j)
t = 1;
break
end
end
end
end
|
function [maxd, iter] = maxeig(M)
% Resolve max eigenvalue for symmetric matrix using iteration method.
% Example:
% M = randn(4)*diag(10.^[1:4]); [maxd, iter] = maxeig(M*M');
%
% See also tr3, det3, inv3, adj3, svd3, foam, B33M44, svdest, vortech
% Copyright(c) 2009-2020, by Gongmin Yan, All rights reserved.
% ... |
function OUT = DLV_dailydata_v45(cd,FN_HA,FN_HALI,FN_HADD,cd_H)
% This function produces the 'daily data' from the delaval backups
% >>> software version v4.5
%
%
% INPUTS: cd current directory: folder of txt DATA files
% cd_H current directory headers: forlder of txt HEADER files
% FN_HA... |
% 2520 is the smallest number that can be divided by each of the numbers
% from 1 to 10 without any remainder.
%
% What is the smallest positive number that is evenly divisible by all of
% the numbers from 1 to 20?
2*3*5*7*11*13*17*19*2*2*3*2
% ans = 232792560 |
N = 16;
% G is an N+2 by N+2 full matrix with border entries set to zero
G = numgrid('S',N+2); % íSí means square with columnwise ordering
% A is the n by n five-point Laplacian sparse matrix, where n=N^2
A = delsq(G); % "del-squared" is a common term for the Laplacian
% N by N matrix of the given N^2 eigenvalues
lam... |
clear; close all; clc;
Freq = 122.76e6;
% ЧАСТОТНЫЙ СИГНАЛ I
L1F_PT = zeros(1,511);
x = [1 1 1 1 1 1 1 1 1]; % Стартовая последовательность
for i = 1:511
L1F_PT(i) = x(7);
x_temporary = xor(x(5), x(9));
x = circshift(x,[0 1]);
x(1) = x_temporary;
end
L1F_PT(L1F_PT==1)=-1;
L1F_PT(L1F_PT==0)=1;
%% ЧАСТОТНЫЙ... |
function [finished] = CombineGCode(folder_name)
%COMBINEGCODE combines all of the trajectory perturbations into 1 file
%
%INPUTS:
% folder_name = the folder where all of the perturbation trajectories
% live
%OUTPUTS:
% finished = indicator that the code has finished sucessfully
finished=0;
d = ... |
% Collect response from handle
% Jan R Wessel 2016, www.wessellab.org
% THIS WAS EDITED FOR SPECIFIC PURPOSES WITHIN ALT
% Usage:
% startttime = handle_response(daq, onoff, side, speed)
% Inputs:
% daq (int) = daq number from DaqDeviceIndex
% ms (int) = record for how long? (ms)
% Outputs:
% RT (int) = RT in ... |
function interpCompare(orbData,mz1,op1,mz2,op2)
% Need to compare a single spectrum from the orbitrap data, i.e. raw data
% to the interpolated forms (both Da and ppm style)...
mzRange = [885.4 885.6];
raw = orbData{1};
numS = size(raw,2);
% Spectral masks
mask1 = mz1 > mzRange(1) & mz1 < mzRange(2);
mask2 = mz2 >... |
[imgs,time] = preProcVSFP1(718,'0');
blur3 = spatialAvg(imgs.imgDR,3);
blur5 = spatialAvg(imgs.imgDR,5);
avg = vsfpAvg(blur5,8);
figure
subplot(3,1,1), plot(time(600:1000),squeeze(imgs.imgAf(60,20,600:1000)./100-1))
% [PxxA, freqA] = pwelch(squeeze(imgs.imgA(60,20,:)),[],[],2^12,200);
% subplot(3,2,2), plot(freqA,log(... |
% Computes the information (I) needed to travel through shortest-paths across pairs of nodes {source,target}.
% adj is the adjacency matrix of a weighted undirected connected graph
% Note that I(source,target) may be different that I(target,source) and
% hence matrix I is expected to be assymetric
function [I] = get_in... |
function [ X, U ] = get_mode_with_linear_counterpart( mex_solver_name, mu_analog, params, xstart )
% For the equation: u_{xx} + (\mu - x^2) u + \sigma_1 \cos(\Omega x) u^3 = 0
%
% INPUT:
%
mu_target = params(1); Omega = params(2); sigma_1 = params(3);
mu_aug = 0.05; % augmentation to bifurcate from zero solution
mu_s... |
function [proj_Input, eigvecs, pca_mean] = perform_pca(Input, NumComponents)
w_len = size(Input.left, 2);
% Concatenate Q matrix across left and right trials and perform PCA on it.
pca_input = [Input.left, Input.right];
pca_mean = mean(pca_input, 2);
pca_input_centered = pca_input - pca_mean;
[e... |
function pkplot(PKdata,X,Y,varargin)
% Plots cell arrays contained in a structure PKData PKData.(X){i} vs
% PKData.(Y){i} for all i
% varargin{1} can specify colormap
%
% T Hennen 2013
if(~ishold)
washeld = false;
axes1 = axes;
box(axes1,'on');
hold(axes1,'all');
xlabel(X);
ylabel(Y);
else
... |
% Test Cases:
[sorted1, ingredients1] = veggieParty(dishCA1, 'Yelp', 'ingredients.txt');
[sorted1_soln, ingredients1_soln] = veggieParty_soln(dishCA1, 'Yelp', 'ingredients.txt');
% sorted1 =>
% 'Dish' 'Michelin' 'Yelp'
% 'stuffing' [ 82] [ 66]
% 'gua... |
fs = 10000;
t = 0:1/fs:3;
A = 5;
B = 100;
f = 3;
w = 2 * pi * f;
x = A * sin(w * t);
xn = x + B * (rand(1, length(t)) - 0.5);
xs = x(1:fs);
subplot(2, 1, 1);
plot(xn);
y = xcorr(xs, x);
subplot(2, 1, 2);
plot(y); |
%Load irish of observed values
testperson = load('testperson.mat');
testirish = testperson.iriscode;
testrowirish = testirish(1,:);
newiriscodeoftestperson = zeros(1,20);
counter1 = 1;
for i=1: 30
iris_value = testrowirish(i);
if (iris_value == 0 || iris_value == 1)
newiriscodeoftestperson(counter1) =... |
function out = getStimulus(obj,key,varargin)
params.frames = 300;
params.rf = 1;
params = getParams(params,varargin);
% get RFs
[snr gfit] = fetchn(RFFit(key),'snr','gauss_fit');
% get only good rfs and combine
gfit = mean(cell2mat(gfit(snr>mean(snr)/2)'),2);
% get the rf info
im = fetchn(RFMap(key,'masknum = 1 an... |
function [CheckResult, TargetPtXi, TargetPtYi,PtNumber] = RowCheck(xySery,Nodes,CheckWhat)
%---------------------------------------------------------------
% CheckWhat == 5 means check winner
% == 4 means check 4 series
% == 3 means check 3 series
%--------------------------------------------------... |
function [xs,tris]=readstl_ascii(filename,dsmin)
%NOTE: STL is a terrible and wasteful format, though it is popular. To be
%at all practical, this file should be compiled.
%ALSO NOTE: STL contains no specific connectivity information. As a result,
%nodes are repeated and repeats must be deleted.
if(nargin <2)
dsmin... |
function b = nlink_alphas_DAE_b_4(in1,in2,in3,g,in5,in6,in7,rest,in9)
%NLINK_ALPHAS_DAE_B_4
% B = NLINK_ALPHAS_DAE_B_4(IN1,IN2,IN3,G,IN5,IN6,IN7,REST,IN9)
% This function was generated by the Symbolic Math Toolbox version 8.1.
% 04-Dec-2018 17:34:12
L1 = in2(1,:);
L2 = in2(2,:);
L3 = in2(3,:);
d1 = in3(1,:);... |
classdef enumSWELimiter < int8
enumeration
OnDepth (1)
OnElevation (2)
end
end
|
function argout = traspaso(o, mat, text)
%con z altura del plano(incluido en mat), o el numero de puntos por corte y mat el vector de
%distancias obtenido y text el archivo a cubrir
for i=1:1:o
pri = [mat(i,1)*cos(mat(i,2)) mat(i,1)*sen(mat(i,2)) mat(i,3)];
fprintf(text(1),'%5.8f %5.8f %5.8f %5.8f \r\n',pri);
... |
cd ('/net/stanley/data/keithn/020205kd/020205kd/func/pain/RESULTS/cl_delay0.00')
h=read_hdr('spmT_0002.hdr');n=1;
disp('constant delays = 10 seconds');
disp('delay L insula ACC R temporal lobe');
for k = -0.4:0.2:1.0
str=sprintf('a = read_img2(h,''../cl_delay%3.2f/spmT_0002.img'');',k);
eval(str... |
function service_sendTracks( mode , test , debug )
if nargin < 3, debug = []; end
if nargin < 2, test = []; end
if nargin < 1, mode = []; end
if isempty( debug ), debug = false; end
if isempty( test ), test = false; end
if isempty( mode ), mode = 'start'; end
global G_sendTracks
mode = lower( mode );
switch mode
... |
classdef PlanReferenceObjects
%PLANREFERENCEOBJECTS [please add info on me here :<]
properties
planUids
planLabels
labelsForPlan
rtdoseForPlan
rtimageForPlan
rtstructsForPlan
ctSeriesForStruct
refUids
end
methods
function ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.