text stringlengths 8 6.12M |
|---|
clc
clear;
width = 128;
height = 128;
[x z] = meshgrid(1:width, 1:height);
x = x - width/2;
z = z - height/2;
z = -z;
x = x/10;
z = z/10;
y = 0*x + 0*z + 4;
rgb = ones(height,width,3)*128;
[theta phi rho] = cart2sph(x,y,z);
save('plane.mat', 'x', 'y', 'z', 'theta', 'rho', 'phi'); |
N = length(Gyrobase);
F = eye(3);
H = eye(3);
Q = diag([1e-1 1e-1 1e-1]);
R = [88.4331 -43.8488 41.1907;...
-43.8488 169.9083 70.4014;...
41.1907 70.4014 112.5151];
%preallocate
x = cell(2,N);
P = cell(2,N);
C = cell(1,N);
x{1,1} = [-5.5783; 3.7975; -37.5309];
P{1,1} = zeros(3);
for k = 2:N
x{1,k... |
% Script to correlate the preceptual ratings with overall depth in brain model
% response
% example for testing this analysis out on noise images
% simulate 5 image pairs
for m = 1:5
display(['image ' num2str(m)]);
% perceptual rating for this image comparison
more3D(m) = rand;
brain1 =... |
% Script for iterative solving of laplace equation
% load data
% Get polygon ROI containing hot data
% (can be replaced with any method for excluding heating, noise, or
% artifact.)
imagesc(abs(dat0(:,:,40)))
roi0=roipoly;
dat3=dat0;
% Phase One: Laplace Integration across entire image:
%This iteration makes a low ... |
clear all
clc
close all
addpath('MY FUNCTIONS');
load('my_database.dat','-mat');
%% Intilize paramters %%
fs = 8000;
sound_id=length(data_save);
%% Read binary file %%
fileID = fopen('data_record.bin');
%rec_data = fread(fileID,[4096*4 1],'float');
rec_data = fread(fileID,[hex2dec('f80') 1],'float');
fclose(fileID);... |
function bw = drawCells(bw)
% lets the user outline objects in the image on the current axis
sz = axis;
sz = round([sz(4)-sz(3), sz(2)-sz(1)]);
if nargin<1 || isempty(bw)
bw = false(sz);
end
assert(size(bw,1)==sz(1) && size(bw,2)==sz(2))
r = 3; % dot radius
outlines = {};
undoBuffer = {bw};
printInstructions
w... |
function o = psjavascript(txt)
%PSJAVASCRIPT Execute the given text as JavaScript and return the result.
% O = PSJAVASCRIPT(I) I is the JavaScript text. O is the result as text.
%
% This routine uses the standard string interface and will do local code
% page conversion of your strings. It is recommended that yo... |
% test for nd_assembly and nd_mult
nel=[5,4,3]
h = [1,1,1]
expand=1.3
A = diag([1 1 1])
lambda=[]
params=[]
X = regular_mesh(nel,h,expand);
plot_mesh_3d(X)
K=nd_assembly(A,X,lambda,params);
x=ones(size(X{1}));
y=nd_mult(K,x);
err_zero=big(y) % should be zero |
function[R] = Rcalc3(v);
%RCALC3 - computes 3d rotation matrix for a vector to [1 0 0]
if size(v,2)==1
v = v';
end
%first rotate from xy plane to x direction
Lxy = norm(v(1:2));
if Lxy==0 %v is solely in Z direction
R1 = eye(3);
else
ca = v(1)/Lxy;
sa = v(2)/Lxy;
... |
function min_val = robust_min(indata, percentile, dim)
% function min_val = robust_min(indata, percentile, dim)
%
%
% Get the minimum of INDATA bar the top PERCENTILE % of data points.
% Useful for e.g. setting colormap ranges that are not overly affected by
% individual outliers.
%
% Operates on N-D arrays a... |
function bin=en_coef3dB(Lev_sub,delta0)
wh=2; px0=1;
load H3L1
n8=H3cutted(px0,8,n)'+1;
n8=[n8(2,:); n8(3,:); n8(1,:)];
n7=H3cutted(px0,7,n)'+1;
n7=[n7(2,:); n7(3,:); n7(1,:)];
n6=H3cutted(px0,6,n)'+1;
n6=[n6(2,:); n6(3,:); n6(1,:)];
n5=H3cutted(px0,5,n)'+1;
n5=[n5(2,:); n5(3,:); n5(1,:)];
n4=H3cutted(px0,4,n)'+... |
%--- coordinate plot with respect to time
% you need to define model.C_posn in order to work properly
file= 'exa3_1';
load([ '1filter_',file,'.mat']);
[X_track,k_birth,k_death]= extract_tracks(X,track_list,total_tracks);
figure(1); clf; subplot(211);
figure(2); clf; subplot(211);
figure(3); clf;
%--- plot true tra... |
function ind = get_leaf_ids(G)
[junk,ind] = find( G.LeafIds ); |
function matEvaluateSourceTerm( obj, fphys )
% frhs = frhs + BottomTerm
obj.matEvaluateTopographySourceTerm( fphys );
% frhs = frhs + CoriolisTerm
obj.coriolisSolver.evaluateCoriolisTermRHS(obj, fphys);
% frhs = frhs + FrictionTerm
obj.frictionSolver.evaluateFrictionTermRHS(obj, fphys);
% frhs = frhs + WindTerm
obj.win... |
function R2 = AMIGO_R2test(residuals,data)
%R2 = AMIGO_R2test(residuals,data)
% Computes the R-square value of a model
% R: matrix or cell vector of residuals: difference between prediction and
% data
% D: matrix or cell vector of calibration data
%
% TIP: put the different experiments into cells R{iexp}, D{iexp}
% PU... |
close all; clear all; clc;
x0=input('Anfangsbedingung, x0: ');
v0=input('Anfangsbedingung erste Ableitung,dx/dt 0: ');
tf=input('Ende des Zeitsraum, tf: ');
h0=input('Schrittweiten, h0: ');
f=@(t,x,v) -10*sin(x);
%Anfangsbedingungen
t0=0;
hold on
%Runge-Kutta-Verfahrung h0
[t3,x3,v3]=RK2(f,t0,tf,x0,v0,h0);
... |
clc; close all; clear all;
%DataRoot = 'C:\Users\lucaswang\Documents\Visual Studio 2015\Projects\reLocalizer\reLocalizer\output';
DataRoot = 'output';
DataDir = fullfile(DataRoot, 'cloud_mov.pcd');
cloud_mov = pcread(DataDir);
DataDir = fullfile(DataRoot, 'cloud_ref.pcd');
cloud_ref = pcread(DataDir);
figu... |
close all
clear all
clc
co2_file = load(['/home/carltonx/Documents/Smear_course/CO2_data.txt']);
ntot_file = load(['/home/carltonx/Documents/Smear_course/Ntot.txt']);
%kk = datenum(co2(:,1:6));
day = 152 ;
co2 = co2_file(:,7);
ntot = ntot_file(:,7);
for j = 1:1440
time(j) = (j/48 - 1/48) + day;
end
... |
function dGrf_heel_c5_s = dGrf_heel_c5_s(in1,in2)
%DGRF_HEEL_C5_S
% DGRF_HEEL_C5_S = DGRF_HEEL_C5_S(IN1,IN2)
% This function was generated by the Symbolic Math Toolbox version 8.4.
% 08-Jul-2020 23:05:59
q1 = in1(:,1);
q2 = in1(:,2);
q3 = in1(:,3);
q4 = in1(:,4);
q5 = in1(:,5);
q6 = in1(:,6);
qd1 = in2(:,1);... |
function [ norm_vector ] = DES_GaussNorm( vector )
%GAUSS_NORMAL Summary of this function goes here
% Detailed explanation goes here
% output_args = exp(-(vector-max(vector)).^2/((max(vector)-min(vector)/2)^2));
mean_v = (max(vector)-min(vector))/2;
max_v = max(vector);
norm_vector = exp(-(vector- max_v).^2... |
function [ J, gradJ ] = Least_Squares_obj(X_op)
%UNTITLED Evaluates the Objective function and its gradient
%% Load the sensor data and set some dimensions
load dataset2.mat
M = 2*length(l); %No of landmarks
K = length(X_op) - M; %No of timesteps
dim = 3;
Y_r = r(1:K/dim,:);
Y_b = b(1:K,:);
Y_v = v(1:K);... |
%% Preambule
mu=0.02;
sigma=0.2;
time=82/252;
yield=0;
Strike=12;
Start=20;
%% 1D Plots
ValueCall=[];
ValuePut=[];
sigmavec=[];
resolution=0.01;
for i=1:200,
sigma=0+i*resolution;
[A,B]=blsprice(Start,Strike,mu,time,sigma,yield);
ValueCall(end+1)=A;
ValuePut(end+1)=B;
sigmavec(end+1)=sigma;
end
sub... |
function lightningPlot( data , varargin )
%lightningPlot takes in WWLLN formatted data and genrates a global plot.
%
% Written By: Michael Hutchins
%% Load coastal data
load coast_high
%% Read input parameters
crop = false;
density = false;
res = 0.5;
for i=1:length(varargin)
... |
function F = uq_gumbelmin_pdf( X, parameters )
% UQ_GUMBELMIN_PDF(X, parameters) calculates the Probability Density Function
% values of samples X that follow a minimum Gumbel distribution with parameters
% specified in the vector 'parameters'
%
% NOTE: This function refers to the *minimum* Gumbel distribution. For m... |
%% Calculate average Pearson correlation coefficient for metabolic pathways
% Load table of PCC values for flux data (ATP/P1/P2)
% corr_ATP = array2table(corr_ATP,'VariableNames',{'PCC'});
% corr_P1 = array2table(corr_P1,'VariableNames',{'PCC'});
% corr_P2 = array2table(corr_P2,'VariableNames',{'PCC'});
% Selec... |
function [ correctedx, correctedy ] = windCorrect( FlightData, fieldx, fieldy )
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
correctedx = FlightData.(fieldx) - cumsum(FlightData.WindDelta(:,1));
correctedy = FlightData.(fieldy) - cumsum(FlightData.WindDelta(:,2));
end
... |
%Script file: Power in a resistor
%MATLAB Programming for Engineers: Problem 2.25
%
%Purpose: The voltage across a resistor is related to current flowing
%through it by Ohm's Law:
% V = IR
%
%Author: Ayaz Noor
%Date: 1/10/21
%Define variables:
% res --resistor
% cur --current
% vol --volts
% pow --... |
function bir180 = genBIRpulse(sweepWidth, Tseg)
% function bir180 = genBIRpulse(sweepWidth, Tseg)
% SweepWidth is in KHz
% dt = 1e-3; % ms
% Tseg is in ms
% Npoints = Tseg/dt;
dt = 1e-3; % ms
Npoints = Tseg/dt;
t=linspace(0,Tseg,Npoints);
zeta = 15;
kappa = atan(60); % 1.5541;
tankappa = 60;
%wmax = 0.389 *2*pi; %... |
classdef NdgNoneHorizDiffSolver
%NDGNONEHORIZDIFFSOLVER 此处显示有关此类的摘要
% 此处显示详细说明
properties
end
methods
function obj = NdgNoneHorizDiffSolver( physClass )
%Doing nothing
end
function matEvaluateDiffRHS(obj, ~, ~)
%Doing noth... |
function [ Receiver_locs, Transmitter_locs] = Transducer_Init(S_Resolution)
% Initialization of values
%initial receiver locs
%Receiver_locs = [100,100,100; 100,100,-100; 100,-100,100; 100,-100,-100; ...
% -100,100,100; -100,100,-100; -100,-100,100; -100,-100,-100];
i=1;... |
close all;
clear all;
%JMA: uiPtbCorgiData loads project data
ptbCorgiData = uiGetPtbCorgiData();
%Set some figure options:
figurePosition = [0 0 1000 500];
%JMA: Next let's loop through each participant and each condition.
%
for iParticipant = 1 : ptbCorgiData.nParticipants,
%JMA: get the data for this pa... |
%alpha = -0.9
a=-0.9;
n=0:50;
l=-50:50;
f=-0.5:0.01:0.5;
x=a.^n;
rxx=(a.^abs(l))/(1-(a^2));
Sxx=(1./(1-(2*a*cos(2*pi*f))+a^2));
figure
subplot(1,3,1);
stem(n, x);
xlabel('n');
ylabel('x(n)');
title('alpha = -0.9');
subplot(1,3,2);
stem(l, rxx);
xlabel('l');
ylabel('r_{xx}(l)');
subplot(1,3,3);
stem(f, Sxx);
xlabel('... |
% This script loads spike counts and check each cell's block trials' rule
% encoding by using ROC.
clear
SD = load('/Users/lixiangci/Documents/MATLAB/ProAntiData/pa_sesstab.mat');
CD = load('/Users/lixiangci/Documents/MATLAB/ProAntiData/pa_celltab.mat');
SD = SD.sesstab;
CD = CD.celltab;
load('../mats/SessionInfo.mat'... |
function freqPanel=FreqPanelDPOAE(T, EXP, Prefix, CmpName);
% Panel for simple frequency selection
%
[Prefix, CmpName] = arginDefaults('Prefix/CmpName', '', 'Title');
if isequal('-',T), T = 'F1 and F2'; end
DACstr = getDACstr(EXP.AudioChannelsUsed, EXP.Recordingside);
ClickStr = ' Click button to select ';
% ... |
clear all
clc
lambda = 1/15;
mu = 1/936.65;
for i=1:101
P = (i-1)/100;
x_t = creat_generator(lambda, mu, P);
xt(i,:) = x_t(1e6);
p_long_miss_park(i) = sum(xt(i,:)) - xt(i,1) - xt(i,5);
p_short_miss_park(i) = xt(i,8) + xt(i,10);
end
figure()
m = {'+','o','<','.','x','s','d','*','p',... |
function change_spectogram_contrast_Callback(hObject, eventdata, handles)
clim_change = [0,0];
if ~isempty(eventdata)
switch eventdata.Source.Tag
case 'high_clim_plus'
clim_change = [0, .1];
case 'high_clim_minus'
clim_change = [0, -.1];
case 'low_clim_plus'
... |
%Generates Figure 2 of the paper
load('precomputedSynthetic.mat')
n = 40^2;
rtn = sqrt(n);
Ctwelve = generateTwelve(n, 1);
ht = 0.5*log(1 + sqrt(2));
betaCands = (-0.02:0.005:ht);
ht = betaCands(end);
params = logspace(-3, 0, 75);
numTrials = 500;
numMples = zeros(length(params), 1);
numStats = zeros(length(... |
function [TKB TBK R T]=findRotation(p0,p1,p2)
clf;
% p0=[0.03;-0.15;0.95];
% p1=[0.15;-0.15;0.95];
% p2=[0.03;-0.09;0.81];
X1=(p2-p0)/norm(p2-p0,2);
Y1=(p1-p0)/norm(p1-p0,2);
Z1=cross(X1,Y1);
X0=[1;0;0];
Y0=[0;1;0];
Z0=[0;0;1];
R=[dot(X1,X0) dot(Y1,X0) dot(Z1,X0);dot(X1,Y0) dot(Y1,Y0) dot(Z1,Y0);dot(X1,Z0) dot(Y1,Z... |
function [MI] = compute_MI(env,fn)
% compute the mutual information between an environmental probability
% distribution (with unit spacing) and the Fisher information in a neural
% population
H = -sum((env/sum(env)) ... % entropy of probability density prior distribution
.* log((env/sum(env)))); ... |
function [pss,is_pss,r] = dss2ss(ipss)
%DSS2SS Converts a descriptor state space model into a proper state space
%model.
% Converts a descriptor state space model into a proper state space
% model. States that are unnecessary are removed. This does not include a
% possible cancellation of poles and zeros.
% In ... |
% EJERCICIOS RESUELTOS DE VISIÓN POR COMPUTADOR
% Autores: Gonzalo Pajares y Jesús Manuel de la Cruz
% Copyright RA-MA, 2007
% Ejercicio 14.5: Fusión de imágenes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 14.4.5 Descomposición piramidal del gradiente
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%... |
function exp = buildTivaroVstmScreen(screenType, exp, trialIndex)
% build a screen for exp.currentTrial or trialIndex, and store it in the
% experiment screen screenType is a string telling which screen to build:
% 'blank' for a blank screen (background color)
% 'fixation' for a blank screen with only a fixation cross... |
% ajedrez
function grano = entrada(x)
n=0:x;
r=2.^n;
s=sum(r)
t=5/60/60/24/365 |
close all;
clear all;
load h.txt
subplot 211;
plot(h, '.'); grid
xlabel('n');
title('h(n)');
f = 0 : 100 : 300000;
M = abs(freqz(h,1,f,101000));
subplot 212;
semilogy(f/500, M); grid;
axis([0 200 0.000001 10]);
xlabel('f[kHz]');
title('Mag[H(f)]'); |
%I=zeros(640,480);
%imshow(I);
I=zeros(480,640);
% % % 70x50 BIR DIKDORTGEN CIZDIRME
% % for i=100:170
% % for j=120:170
% % I(i,j)=1;
% % end
% % end
% % imshow(I);
% % % 200,200 NOKTASI ETRAFINDA GRADYEN OLARAK AZALAN BEYAZ BIR DAIRE CIZDIRME
% % for i=1:480
% % for j=1:640
% % if (200-... |
%% Assignment 3: Measuring the speed of the attentional scanner
% Please execute the while loops separately if they don't all work together at the same time. And please be gentle--thank you.
% Be advised: certain functions can only be executed with matlab version 2016 and above,
%% Init
clear all
close all
clc
%% ... |
%--------------------------------------------------------------------
% Bandpass the signal up to the 4th harmonic
% y - raw signal
% fs - raw sampling freq
% ord - order of the filter (tested @ 60)
% Ap - pppassband ripple (tested @ 0.1)
% first_n_harm - first n harmonics. (tested @ 4) Do not use more than 4.
% bandw... |
function Fout=interp2_cyclic(u,v,F,uout,vout,N)
% u must be 2*pi periodic.
% v must be 2*pi/N periodic.
vDirection=sign(v(1,end)-v(1,1));
uDirection=sign(u(end,1)-u(1,1));
vbig=[v,v(:,1)+vDirection*2*pi/N];
vbig=[vbig;vbig(1,:)];
ubig=[u;u(1,:)+uDirection*2*pi];
ubig=[ubig,ubig(:,1)];
Fbig=[F,F(:,1)];
Fbig=[Fbig;Fbi... |
function[noncomp,comptable] = check_compliance(Deployment_roomcat_save, bname,noncomp,comptable,psname)
% by Evan Coffey
% Ceates plots from the beacon deployments of proximity to stove and CO
% exposure by compliance type
%Compliance 1
compliance1 = Deployment_roomcat_save.HAPEX_1_Compliance;
totcomp... |
x0 = single(imread('lichen_lava.png'))/255;
s = 1; % scale
% s = [480,640];
x0 = resize_image_2D(x0,s);
x0 = Spectrum.periodic(x0); % a nuance, periodize image for periodic patches
x0 = gpuArray(x0);
N_scales = 5;
N_iter = 16;
patchsize = 4;
dataratio = .35;
match_heuristic = 'BS';
% match_heuristic = 'OT';
% match_h... |
function [bits_depunct] = depuncture_bits(bits_deinter,R)
N = length(bits_deinter);
if R == "1/2"
bits_depunct = bits_deinter;
elseif R=="3/4"
bits_depunct = [];
n = 1;
while 1
if (n+1) <= N
bits_depunct = [bits_depunct;bits_deinter(n:(n+1))];
else
br... |
function wave_sliders
% Open UI window with 8 sliders analoguous to pmod bar plot
% After each change we rewrite:
% --> custom_betas
% --> remainder_coeff
% --> and call wave_plot_fitted_response
ylims = wave_load_ylims;
betas = wave_load('betas', [10 1]); % Initialize at original_betas
slider_names ... |
function [reachabilityTime, verificationTime, time, safe] = rendezvous_4np_mhypro(saveFig, savePath, figName, bad, diff,settings,setRepr,aggr, plotting)
timeHorizon = 20;
% Create Automaton
automaton = MHyProHAutomaton();
dummy_reset = MHyProReset();
dummy_reset.setMatrix(eye(6));
dummy_reset.setVector([0; 0; 0; 0; 0... |
% Copyright (c) 2017, Amos Egel (KIT), Lorenzo Pattelli (LENS)
% Giacomo Mazzamuto (LENS)
% All rights reserved.
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are met:
%
% * Redistributions of source ... |
function [tPosMat,fPosMat,tNegMat,fNegMat,precMat] = calculate_thresh_acc(Fass,C,sims)
% calculates tpos rate and fpos rate for DEEP structure at all
% accuracy thresholds (for plotting ROC curves)
% Fass is n x n x T (count of detections)
% C is n x n (ground truth condition)
[~,n,T] = size(Fass);
[n1,~] = siz... |
% % 最大持续盈利次数,输入参数R是交易盈亏情况
function maxConGainTimeRet = maxConGainTime(R)
R(R>0) = 1;
if R(end) == 1
R = [R;-1];
end
indexMax = 0;
maxTemp = 0;
for i = 1:length(R)
if R(i) == 1
maxTemp = maxTemp + 1;
else
... |
function [ data, Info ] = ph1valid02_classify( subjid, which_th, experiment )
%PH1VALID02_CLASSIFY Summary of this function goes here
% Detailed explanation goes here
%% 0. setup
if nargin < 1
subjid = 'VP26';
which_th = 'Threshold';
experiment = 'Rp';
elseif nargin < 2
which_th = 'Threshold';
e... |
function [ap, rec, prec] = computeAP(out, gt, poslabel, neglabel, draw)
% Given a list of confidences (in out) and the corresponding gt, compute AP
% Code is based off VOCevalcls
if ~exist('draw', 'var') || isempty(draw)
draw = false;
end
if ~exist('poslabel', 'var') || isempty(poslabel)
poslabel = 1;
end
i... |
frames = [120 121 123 128 150];
%legends = cell(size(frames));
colors = 'rgbkcym';
figure;
subplot(1,2,1);
for i=1:length(frames)
plot(1:size(features_tr,2),features_tr(frames(i),:)+(i-1)*0.3,colors(i));
%legends{i} = sprintf('%d', trainlab(frames(i)));
hold on;
end
legend(legends{:});
subplot(1,2,2);
for... |
function plot_prospective_pfcfwdreplays(thisdir,label,smoothsize)
load(thisdir,[label '_replay_singlebothjoint'],[label '_Cand_sig_modu_include'], ...
[label '_PFCreplayspikes_binned'],[label '_PFCreplayspikes_list'],[label '_replay_shuffle_p']...
,[label '_replay_replayarm'],[label '_replay_stnd'],'pos','... |
function [W,S] = TurbineBladesData(mf,N,h,rm,V1,rho)
% Calculation of throat width
At=mf/(rho*V1);
W=At/(N*h);
% Calculation of spacing
S=(2*pi*rm)/N;
end |
function [J, grad] = costFunction(theta, X, y)
%COSTFUNCTION Compute cost and gradient for logistic regression
% J = COSTFUNCTION(theta, X, y) computes the cost of using theta as the
% parameter for logistic regression and the gradient of the cost
% w.r.t. to the parameters.
% Initialize some useful values
m = l... |
function [fig, P] = quick_look_pitot(data, W, vis)
%% [fig, P] = quick_look_pitot(data, W, [visible])
%
% This function does a quick Pitot calibration based on the calibration coefs
% in W including epsilon and spectrogram
%
% INTPUT
% data : standart output of quick_look, or quick_calibrate
% W : cali... |
function [r] = interactionGraph(A, reorder)
%
% function [r] = interactionGraph(A, reorder)
%
% Author:
% (c) Matthias Chung (mcchung@vt.edu)
% Justin Krueger (kruegej2@vt.edu)
%
% Date: June 2015
%
% MATLAB Version: 8.4.0.150421 (R2014b)
%
% Description:
% This code produces a directed graph with the colors ... |
function [aver,aver2,Xaver,Xaver2]=perm_stats(GRC1,GRC2)
%Select combinations.
F= [1 2; 1 3; 2 3] ;
wb=waitbar(0,'wait')
for j=1:3
waitbar(j/3,wb,'wait')
f=F(j,:);
%Baseline
%First direction
gr1=abs(squeeze(GRC1(f(1),f(2),:,:)));
ggr1=gr1-mean(gr1... |
%% reject ICs
if s >= 100
zeroes = ''
else
if s >= 10
zeroes = '0'
else
zeroes = '00'
end
end
cd(preprocdir);
EEG = pop_loadset( 'filename', [num2str(group),num2str(zeroes),num2str(s),'-',dose,'-PostR-ICA.set'], 'filepath', [preprocdir,nu... |
function [par,partition] = get_partition (lower, upper, point,v)
% count the number of partition
sort(point);
partition = 1;
par = 1;
array = [point lower upper];
sort(array);
if length(point)>0
for i = 1:length(point)
if i < length(point)
if point(i) == point(i+1)
partition... |
function out = elastic_prediction(f, t, model, option)
% This function identifies a logistic regression model with
% phase-variablity using elastic methods
%
% input:
% f (M,N): matrix defining N functions of M samples
% t : time vector of length M
% model: model structure from elastic_regression, elastic_logistic, or
... |
function main
global drytol g
%physical parameters
g=9.81;
%dry cell tolerance
drytol=1e-3;
%setup domain
xmin=-50;
xmax=150;
t0=0;
tfinal=240;
nx=200; %number of cells
cfl=0.5; %Courant number
%very crude upper bound on largest wave speed
c=5;
%set up grids
dx=(xmax-xmin)/nx;
xcenters=linspace(xmin+dx/2,xmax-dx/... |
function [p, D, allD]= Dominance_shoelace(a_events, b_events)
% function [p , D, allD]= Dominance_shoelace(a_events, b_events)
%
% (c) Luis Hernandez-Garcia @ UM
% 11.29.2006
% report bugs to: hernan@umich.edu
%
% This function takes two binary time courses and computes Dominance
% It then calculates the signific... |
load('kernel-svm-2rings.mat')
n = length(y);
d = length(x(:,1));
K = zeros(n,n);
for i = 1:n
for j = 1:n
dif = x(:,i) - x(:,j);
nom = sum(dif.^2);
K(i,j) = exp(-(1/(2*0.5^2))*nom);
end
end
K_ext = [K;ones(1,n)];
%% SSGD Algorithm
phi = zeros(n+1,1);
tmax = 1000;
nC = 256;
iter... |
x= input('changed this message');
for i=1:3
%added a line and a comment
if i>2
fprintf('and this one');
end
end
fprintf('%d', x); |
x = 0.234;
num1 = log(x - sqrt(x.^2 - 1))
num2 = -log(x + sqrt(x.^2 - 1))
fprintf('num1 = %.30f \n', num1)
fprintf('num2 = %.100f \n', num2) |
function [Theta,q,S] = iTMCMC(Ns, Nb, log_likelihood, T_nataf)
%% iTMCMC function
%{
---------------------------------------------------------------------------
Created by:
Felipe Uribe (felipe.uribe@tum.de)
Engineering Risk Analysis Group
Technische Universitat Munchen
www.era.bgu.tum.de
------------------------------... |
function pinit = calcEy(e,s,indEi,visualize)
%Defines Yield Portion of Data:
strainLim = 15.0/50; %mm/mm -- strain
%Initial Data with Load less than Load Limit:
indEy = find(e<=strainLim);
eEy = e(indEi(end)+1:indEy(end)); sEy = s(indEi(end)+1:indEy(end));
%Fits Least-Squares Linear Regression to Bearing S... |
num_sen = 3;
num_com = 3;
num_dec = num_sen*num_com;
%computer reliabilities
R_CA = 0.9990;
R_CB = 0.9996;
R_CC = 0.9998;
rc = [R_CA;R_CB;R_CC];
%computer mass
M_CA = 3;
M_CB = 5;
M_CC = 10;
mc = [M_CA;M_CB;M_CC];
%sensor reliabilities
R_SA = 0.9985;
R_SB = 0.9990;
R_SC = 0.9995;
rs = [R_SA;R_SB;R_SC];
%computer mass
... |
% initialize L-BFGS
memory=10;
S = zeros(n, memory);
Y = zeros(n, memory);
YS = zeros(memory, 1);
LBFGS_col = 1;LBFGS_mem = 0;skipCount = 0;
% calculate Tx (here known as Rx)
d = - Rx;% stepsize should be always equal to one but acceleration might result through K0
if iter == 1
d = - Rx;
LBFGS_col = 1;
... |
clear
clf
clc
close all
end_t = 30;
meas_interval = 1;
% Set up the environment (the landmark locations).
x_beacons = [20 20 40 20 60 20 80 20 20 -10 40 -10 60 -10 80 -10]';
%x_beacons = [70 20 20 20 70 50 20 50]';% 80 60]';
%P_beacons = 0.001^2*eye(length(x_beacons));
P_beacons = 10^2*eye(length(x_beacons)... |
scan_maps
%subcf=subqcf{3,3}(17:32,17:32);
%subcf=subqcf{3,1}(9:16,1:8);
subcf=subqcf{1,1};%(193:256,1:64);
sz=size(subcf); len=sz(1)*sz(2);
nnn=sum(sum(abs(sign(subcf)))) %%%%%%%%%%%%%%%%%%%%%
rk=int16(zeros(1,len)); rw=rk;
rn=0; rnw=0; Nr=0; flg=0;
map=int8(zeros(sz));
for n=1:len
rnw=rnw+1;
row=rout_row(1,... |
function [X,LastF,Iters] = conjgrad(N,X,Eps_Fx,MaxIter,myFx)
% Function performs multivariate optimization using the
% Hooke-Jeeves search method.
%
% Input
%
% N - number of variables
% X - array of initial guesses
% Eps_Fx - tolerance for diffence in successive function values
% MaxIter - maximum number of i... |
[w_i1, cost_i1, e_i1] = SGD_LR_everyBatch(y, X, w0,batch_size, interval_between_errorbar);
cost_nonpriv = cost_i1;
plot(cost_nonpriv, 'b')
hold on
axis manual
[w_i2, cost_i2, e_i2] = SGD_LR_everyBatch_private(y, X, w0, batch_size, interval_between_errorbar);
cost_priv = cost_i2;
%e_priv = e_i2;
plot(cost_pr... |
close all;
clc;
clear all;
all_dat = readtable("raw_data.csv");
%Declaring Varriables for each reading
current = all_dat.I;
voltage = all_dat.V;
current = all_dat.I;
LS = all_dat.LS;
RS = all_dat.RS;
%Getting radius values
r = abs(LS + RS)*1.2 ./ 2;
I_uncert = .001;
R_uncert = .05;
V_uncert = .1;
%1.2 to correct f... |
function [ data_structure_flagged ] = filter_ace_pressure(tanstruct_in)
%A function to find data points in an ACE pressure measurement that are
%zeros, and remove those measurements.
% *INPUT*
% tanstruct_in: STRUCTURE - contains the gas specific ACE data.
% This structure can be created with 'read... |
function [ ] = plot_data( X, width )
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
% This program will display images in a big image
% X is the picture arranged in a row.
[n,m] = size(X);
if ~exist('width','var') || isempty(width)
width = ceil(sqrt(m));
end;
%% parameter for di... |
clear variables;
close all;
N = 1000;
%question1
figure(1)
y = rand(2,N);
cnt = 0;
for k = 1: N
if (y(1, k)^2 + y(2, k)^2)^(1/2) <= 1
cnt = cnt + 1;
plot(y(1,k), y(2,k), 'gx'); hold on;
else
plot(y(1,k), y(2,k), 'rx'); hold on;
end
end
prob = cnt / N;
pi_exp = prob * 4
N
cn... |
function [PPGraw, PPGindex] = PPGSigProcess(PPG, fs, gr)
%% This section includes the implementation of the PPG Signal Processing Algorithm
% The PPGSigProcess function locates peaks in the PPG signal and
% returns the raw amplitude of the PPG signal as well as the indices of
% these these points.
% Taking the... |
function [A, At, Aos, Atos, Os ] = loadPojectors( geom, numos )
if nargin < 2
numos = 1;
end
Aos = @( x, is )forwardProjectMex( x, geom, numos, is, 'proj,tf' );
Atos = @( x, is )backProjectMex( x, geom, numos, is, 'back,tf' );
A = @( x )forwardProjectMex( x, geom, 1, 0, 'proj,tf' );
At = @( x )... |
function [X, ex] = GE(A,b)
%funkca rozwiązująca zadany układ równań metodą Gaussa-Crouta
%na podstawie: http://we.pb.edu.pl/~jforenc/2006_2007_02/PIF2-2007-Wykl-05-Dzienne.pdf
%i: http://eduinf.waw.pl/inf/alg/001_search/0077.php
%X - rozwiązanie
%ex - błąd rozwiązania
AB=[A,-b];
n=size(A,1);
W=1:n;%numery wierszy
for i... |
function [Subspace, EigenValue] = EVD(X, R)
% 特異値分解を行う関数。
% 入力
% X - 特徴ベクトルを格納した配列。
% R - 生成する部分空間の次元数。
% 出力
% Subspace - 部分空間を張るR本の固有ベクトルを格納した配列。
% EigenValue - 各固有ベクトルに対応する固有値を格納したベクトル。
C = X' * X;
[EigenVector, EigenValue] = eig(C);
[Value, Index] = sort(diag(EigenValue), 'descend');
Eigen... |
function [varargout] = ComplexGaussPhasePDF(varargin)
%
% Calculates the probability density function (PDF) of phase of a complex Gaussian random variable, x + jy,
% where: x~(alpha, s1) and y~(beta, s2) over the support [-pi:step:pi].
%
% P = ComplexGaussPhasePDF(alpha, s1, s2, step)
%
% returns a vector of pr... |
function makePrjPointList_projection1d(gdid)
% make projection point list 'ico-XX.mat'
% gdid : ID of original point list
%
% 1.'ico-XX.mat' の頂点に従って2次元投影 proj_2d を計算する
% 2.'Projection1dFromProjection2d.m' に proj_2d を突っ込んで proj_1d を得る
% 3. proj_1d は 'icoXX.mat' の頂点に従って計算した1次元投影と等しい
%
% proj_2d : structure of projectio... |
function varargout = finalproject(varargin)
% FINALPROJECT MATLAB code for finalproject.fig
% FINALPROJECT, by itself, creates a new FINALPROJECT or raises the existing
% singleton*.
%
% H = FINALPROJECT returns the handle to a new FINALPROJECT or the handle to
% the existing singleton*.
%
% FI... |
function [ drawImg ] = drawRotatedBox(image, corners)
% Function draws bounding box of any orientation
% Using bresenham and figures out the co-ordinates
%
% Usage:
% drawImg = drawRotatedBox(image, box)
%
% Input:
% image = Image on which the box is to be drawn
% box = Box ... |
function [Dist,D,k,w]=DTW(vector1,vector2)
[row,M]=size(vector1);
if (row > M)
M=row;
vector1=vector1';
end
[row,N]=size(vector2);
if (row > N)
N=row;
vector2=vector2';
end
d=sqrt((repmat(vector1',1,N)-repmat(vector2,M,1)).^2);
d
D=zeros(size(d));
D(1,1)=d(1,1);
for m=2:M
D(m,1)=d(m,1)+... |
% Harvest or replace fish
function [this, tank] = behaviour(this, tank)
% Grow based on growCoefficient and foodValue
this = grow(this, this.growCoefficient * this.foodValue);
% Nutrition decrease each day
% Calculate nutrition
this = this.calculateFood(this.foodValue);
% Die of ammonia po... |
function [closestTo, dist] = findClosest(img, vals)
%For all pixels, find which are the closest to each mean index.
mysize = size(img);
valsize = size(vals);
k = valsize(1);
distRGB = zeros(k, mysize(1), mysize(2), 3);
for y = 1:mysize(1)
for x = 1:mysize(2)
for i = 1:k
for j = 1:3
... |
X = [1,2;2,4;3,3]
a = X
mu = mean(X,1)
X(:,1) = X(:,1)- mu(1)
X(:,2) = X(:,2)-mu(2)
sigma = std(a)
X(:,1) = X(:,1)/sigma(1)
X(:,2) = X(:,2)/sigma(2)
|
function Reduced
% Reduced order Kalman filter simulation.
% Estimate the first state of a two-state system.
F = [.9 .1; .2 .7]; % System matrix
%F = [1.1 -.1; .2 .7]; % System matrix
Lambda1 = 1;
Lambda2 = 0;
Q = 0.1; % Process noise covariance
H1 = 0;
H2 = 1;
R = 1; % Measurement noise covariance
Lam... |
function im_blend = poissonBlend(im_s, mask_s, im_background);
s=im_s;t=im_background;
[imbh, imbw, nb] = size(s);
im2var = zeros(imbh, imbw);
im2var(1:imbh*imbw) = 1:imbh*imbw;
%initialization
b= zeros(imbh*imbw,3);
A=sparse(imbh*imbw,imbh*imbw);
v=zeros(1,imbh*imbw);
e=1;%which equation
for x=1:imbw
for y=... |
clear
err_history = [];
test_history = [];
for i = 1:1000
clearvars -except err_history test_history
test_net
testing
err_history = [err_history, err];
test_history = [test_history, test_err];
if err < 0.16
if test_err < 0.16
save net;
end
end
end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.