text stringlengths 8 6.12M |
|---|
% xDDP [%N_XP%x1]
% Generalized platform accelerations
|
function x=fsubstituicaoLU(n,A,b)
%L.c=b
c(1)=b(1)/A(1,1);
for i=2:n
soma=0;
for j=1:i-1
soma=soma+A(i,j)*c(j);
end
c(i)=(b(i)-soma)/A(i,i);
end
c
%U.x=c
x(n)=c(n);
for i=n-1:-1:1
soma=0;
for j=i+1:n
soma=soma+A(i,j)*x(j);
end
x(i)=(c(i)-soma);
end
end |
function result = rectangle_filter4(vertical, horizontal)
% function result = rectangle_filter4(vertical, horizontal)
%
% creates a rectangle filter of type 4
% (white on the top, black on center, white on bottom).
result = ones(3 * vertical, horizontal);
result((vertical+1):(2 * vertical), :) = -2; |
file_name='E_octave_new_new.wav'; % output signal of phase 1
[y, Fs] = audioread(file_name);
figure (3);
plot (y);
y_fft = fft(y);
L =length(y_fft);
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(y,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2+1);
figure(1);
plot(f,2*abs(Y(1:NFFT/2+1)));
titl... |
%Example script for estimation task 1
%This script performs the following actions:
% 1. Constructs a camera model loosely based on an iPhone 6
% 2. Constructs a calibration grid of 1m on a side with 10mm grid spacing.
% 3. Positions the grid somewhere in space
% 4. Places the camera in a 'random' location so that the ... |
%in this prg depth of eq is could be read and cgr sequence is made
%based on condition aplied on variable magcoarse and magcoarse1(modigfr bin
%bound and binbound1)
nvrtx = 4;
filename='cgrz1lessthan35.xlsx';
filename1='cgrz2lessthan35.xlsx';
coarsemag = xlsread(filename);
coarsemag1 = xlsread(filename1);
szm... |
k = 50;
A = getRandomAdjacency(k, 0.50);
Q = getQTeleport(A, 0.5);
Q1 = getQTeleport(A, 0.2);
Q3 = getQTeleport(A, 0.7);
X = [GenMarkov(Q, ones(k,k) / k, 2000).';
GenMarkov(Q1, ones(k,k) / k, 2000).';
GenMarkov(Q3, ones(k,k) / k, 2000).'];
estimateAlpha2(X,A,0.001) |
function process_fista_cluster_check(filename)
S=load(filename);
s_data=smooth(S.data_pad);
map=colormap(jet(S.fista.clust_num));
figure;
for i=1:S.fista.clust_num
subplot(1,S.fista.clust_num,i)
event_index=S.fista.X1_max;
clust_index=event_index(S.fista.X1_clust==i);
%clust_amp=S.fista.X1_integral(S.fista.X1_clust==i)... |
function enu = wgsxyz2enu(p_e,ref_lat,ref_lon,ref_alt)
%%经纬度->当地ENU直角坐标值
p_e_ref = wgslla2xyz(ref_lat, ref_lon, ref_alt);
delta_xyz = p_e - p_e_ref;
enu(1,1)= -sind(ref_lon)*delta_xyz(1) + cosd(ref_lon)*delta_xyz(2);
enu(2,1)= -sind(ref_lat)*cosd(ref_lon)*delta_xyz(1) - ...
... |
function out = preProcVSFP7(fDate, fNum, mouseID, ~)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Preprocessing for VSFP imaging data (Dual Camera Acquisition)
%
% Usage:
% out = preProcVSFP(fDate, fNum, avgGain)
% where: avgGain = 0 or 1 (calculate gain factors from trial avg)
%
% 7/16/2015 - Much faster Vers... |
function [X Y] = file2Training_set(file,image1,image2)
%% prepares training data in order to train SVM
% mode options:
% 1: using sift as features
% 2: using pixel values in a neighbourhood
% 3: using sift vector norm
% 4: using difference of sift descriptors
global file2Training_set_mode;
mode = file2Training_set_mode... |
function [y,sig2,p]=gm_init(x,K,method)
% This function is based on the funciton used in the course Non linear
% signal processing.
% % (c) Lars Kai Hansenn
%function [y,sig2,p]=gm_init(x,K,method)
%
% Initialise a gaussian mixture model
%
% input:
%
% x: training data
% K: number of clusters
% method: 1,2,... |
function [ gps ] = read_gps_data()
GPS = FileToCells('../../data/raw/gps.csv', ',');
% delete row_names column
GPS(:,1) = [];
gps = CellToNumeric(GPS, 1,1);
% obsid, birdid, day, min, ticks, y, x, speed
% 1, 2, 3, 4, 5, 6, 7, 8
% sort by time
ids = ... |
clc;
clear variables;
load('.\ACVMS\ACV42_IR.mat');
matMeanSNR = zeros(sz_simresult(3), sz_simresult(6));
matStdSNR = zeros(sz_simresult(3), sz_simresult(6));
for ctr_noise = 1 : sz_simresult(6)
for ctr_prop = 1 : sz_simresult(3)
matMeanSNR(ctr_prop, ctr_noise) = mean(stArr_simresult(4,1,ctr_prop,1,1,ctr_... |
function varargout = interpsamrai(V, varargin)
% [x,y,V] = interpsamrai(V, ...)
% or
% V = interpsamrai(V,x,y, ...)
%
% Options:
% 'numgrid' - 1 or 2 elements. Specifies the number of points to span
% the space represented in V.
% 'distgrid' - 1 or 2 elements. Specifies the distance between points
% tha... |
function plot_lfp_stim_filters(model, data, processed, fn_out)
%Plot filters of a fitted GLM model, along with other fit statistics
%
%Input:
% model = data structure output by function in ./fitting (containing fitted coefficients)
% data = data structure output by ./models containing data used for fit
% pro... |
% Michael Miller
% ENGR 297 - MATLAB Project Part 1
% april 26, 2016
clear all;
close all;
clc;
%This script uses the function game_info.m
%CPU Player CELL
%Row define as follwed
%
% cpu =
%
%Name 'Sam' 'Max' 'Eve' 'Joe' 'Amy' 'Hal' 'Ivy'
%Hand '2JATQ9' '5K' '64KJ5T... |
% Moth Search algorithm,蛾子群算法,模拟的是蛾子的趋光性
% 将蛾子群分成了两组,第一组离光近,第二组离光远
% 每次都需要对蛾子群排序,这有点杀时间
% 离光远的,用跨大步算法,随机选择一个,这两个一个是越过best,一个是不越过best
% 离光近的,用随机游走法,绕着光源转圈圈
% 算法流程:
% 初始化,生成群解NP,设置参数Smax(跨大步每次跨的最大步长),β(一个指数算子,通常为1.5),加速因子phy
% 计算适应值fitness,对NP根据fitness排序
% for 迭代次数:
% for 1 to N/2: 对厉害组进行随机游走,N是总数
% 随机游走
% ... |
function startTestbed(varargin)
%this script will disconnect the given nodes in CMRI
global TESTBED
if nargin==0
startComm(TESTBED.address{:})
end
for i=1:nargin
index = find(varargin{i} == TESTBED.id)
if ~isempty(index)
startComm(TESTBED.address{index});
end
end
|
function p = gl2cInvert(G)
% returns the principal element of the Lie algebra sl(2,C) corresponding to
% the element 'G' of the Lie group SL(2,C). By principal I mean first
% branch of the matrix log.
K = 1/sqrt(det(G));
T = acos(K*(G(1,1) + G(2,2))/2);
O = T*K/sin(T);
p(1) = 2*1i*log(1/K);
p(2) = 1i*O*(G(1,1) - G(2,2)... |
function [smooth_view] = free_viewpoint(rec_im1,rec_im2,spdmap_lr,spdmap_rl,p)
%% read color images and disparity maps for left and right view and convert them to double values.
% im0: color image of left view
% im1: color image of right view
% disp0: disparity image of left view
% disp1: disparity image of ri... |
function a=RMS(x)
a=sqrt(mean(x.^2));
end |
%CHANGEABSOLUTEPATH Change absolute path contained within a struct.
%
% ------------------------------------------------------------------------
% Copyright (C) 2017 M. Schrauwen (markschrauwen@gmail.com)
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU ... |
function recall=calculate_recall(Y,Y_validation)
Y_size=length(Y);
total_positive_count=0;
total_true_positive_count=0;
for i=1:Y_size
if Y(i)==1 && Y_Validation(i)==1
total_true_positive_count=total_true_positive_count+1;
end
if Y(i)==1
total_positive_count=total_positive_count+1;
end
end
recall=... |
function strFileOut = do_spm_slice_timing(strFileNii,strPrefix,strPreserveHeader,strSliceDir)
% do_spm_slice_timing.m - wrapper for spm8 slice-timing module
%
% INPUTS
% strFileNii - string, filename of .nii to be corrected
% strPrefix - string, prefix that will be tacked on to output name (default 't')
% strPreserveHe... |
%% Reading the output
readpath = "FromCPP/";
filename = "Trial_1_Conv1";
out = readmatrix(strcat(readpath, filename, ".csv"));
Fs = 24000;
%% Extracting L and R Channels
% Normalising
out = out/max(abs(out));
L_idx = 1:2:length(out);
R_idx = 2:2:length(out);
L = out(L_idx);
R = out(R_idx);
%% Writing audio fil... |
clear variables
close all
addpath("./penguinpi-robot")
%% Constants
Kh = 0.2;
Kv = 0.05;
% x, y
map = [0 , 0; % Landmark 1
1, 0; % Landmark 2
2, 0; % Landmark 3
0, 1; % Landmark 4
2, 1; % Landmark 5
0, 2; % Landmark 6
... |
% KL expansion
function Fi = KLexpansion(Nrow,Ncol,Lx,Lz,CorLengthx,CorLengthz,VarF)
% Nrow=31;Ncol=31;
Npd=500;% the number in fun.dat
% Np=100;
Nroot=40;%超越方程的个数
% Lx=200;
% Lz=200;
% CorLengthx=100;
% CorLengthz=50;
% VarF=1.0;
dx=Lx/(Ncol-1)*ones(1,Ncol);
dz=Lz/(Nrow-1)*ones(1,Nrow);
% eigenpairAna_2D
X0RLn=0.1;
... |
%% Implementation details and a clean slate
close all
clear
clc
tic
% This code implements the system of equations described in Jäger et al. (2010)
% in one dimension (z-dim) using a finite difference method, with an added
% layer of benthic algae residing on top of the sediment layer.
% The lake is assumed to be a cy... |
close all;
addpath('laplacian\');
pause('on');
%% laod data and present it
model = load_off('./dataset/shrec/null/cat.off');
partial_model = load_off('./dataset/shrec/cuts/cuts_cat_shape_2.off');
trimesh(model.TRIV, model.VERT(:, 1), ...
model.VERT(:, 2), model.VERT(:, 3));
title("model");
trimesh(partial_model... |
% +KAL Package for all code applied to population analyses using Kalman filter approach
% MATLAB Version 9.7 (R2019b Update 5) 29-Aug-2020
%
% Functions
% computeThirdOrderKf - Compute third-older kalman filter matrix
% estimateKF - Estimate kalman filter data
% getCleanKinematics - A... |
function [x, it] = bootstrap_wrong_derivative(inner_solver, target_alpha, v, R, tol, maxit, relative_speed)
% Calls an inner solver iteratively over increasing values of alpha
% Predicts the new x using a first-order Taylor expansion with a "modified"
% (i.e., wrong) first derivative
if not(exist('tol','var')) || isem... |
function c = wave_load_colors
% returns array with colors for wavepain paper
% earlier version used to read 5 colors from binary file but this is not C
% so we can do it like this
c = [215,25,28;
253,174,97;
255,255,191;
171,217,233;
44,123,182;
119,221,119]./255; |
clc;
clear all;
close all;
im = imread('circles.jpg');
imbw = im2bw(im,0.15);
I = imfill(imbw,'holes');
figure, imshow(im)
title('Original image')
figure, imshow(I)
title('Binary image')
se1 = strel('disk',2);
I2 = imerode(I,se1);
se2 = strel('disk',2);
im3 = imdilate(I2,se2);
figure,imshow(I2)
title('Binary image a... |
function tPM = CombVec( aN, aM, aI )
% function tPM = CombVec( aN )
% Computes the aIth combination vector of aM elements grouped at the front of row vector aN
tPM = zeros( 1, aM );
tI = 0; % running index
tN = aN; % current total number, decrements as we move through columns
iPM = 1; % current column index, increment... |
function [fwfmin,fwfmax,bmin,bmax] = stageI(Xabs,Xang,N,S,fs)
%
% Objetive: The goal of this stage is to estimate the spectral interval,
% defined as band of interest (BOI), in which the probability
% to find wheeze sounds is maximum.
%
% Input:
% - Xabs: Magnitude mixture spectro... |
function bscan = drawIdxOct(bscanOrig, positions, color, opacity, mode)
% DRAWIDXOCT Draws positions (marked as 1 in the positions vector)
% on an OCT BSscan image
if nargin < 5
mode = '';
end
if size(bscanOrig, 3) == 1
bscanOrig(:,:,2) = bscanOrig;
bscanOrig(:,:,3) = bscanOrig(:,:,1);
end
idx = find... |
function result = uq_borgonovo_inner_CDFbased(y0,y_cond0,subids,Y,Xi,y_smooth,ecdf_y)
% results = UQ_BORGONOVO_INNER_CDFBASED(y,y_cond)
% Performs CDF based integration of the abs(y-y_cond) with the method
% described in
%
% Qiao Liu, Toshimitsu Homma (2009) - "A new computational method of a
% moment-... |
A=('/home/klodjan/MEGA/simeiosis/HY370/Lab6Data-Ex2/peppers.png');
k='/usr/local/MATLAB/R2012a/toolbox/images/imdemos/board.tif';
gg='sobel';
m='prewitt';
%G1=SobelGradDetector(A);
%PrewittGradDetector(k);
EdgeDetector(k,m);
|
function obj = modelBatchCopyFiles(obj)
% Copies files from folders to a specific other folder.
% Biafra Ahanonu
% 2015.09.01 [21:36:38]
%
% inputs
%
% outputs
%
% changelog
% 2021.08.10 [09:57:36] - Updated to handle CIAtah v4.0 switch to all functions inside ciapkg package.
% TODO
%
import ciapkg.a... |
%% Flow Noise Sound Power
clear; clc; close all;
U = [10 20 40];
D = 0.11;
RefSoundSoure = load("RefSoundSource.mat");
spl.Ref = load("SPL_1_3_OCT_RSS1.mat");
spl.u10 = load("SPL_1_3_OCT_woTail_u10.mat");
spl.u20 = load("SPL_1_3_OCT_woTail_u20.mat");
spl.u40 = load("SPL_1_3_OCT_woTail_u40.mat");
splT.u10 = load("SPL_... |
classdef TPA_BehaviorTwoPhotonOverlay
%TPA_BehaviorTwoPhotonOverlay - overlays Two Photon ROI dF/F data on behavior image data.
%
%-----------------------------------------------------
% Ver Date Who What
%-----------------------------------------------------
% 2010 2... |
function res = singlenormal( x, sigma, mu )
% Computes the likelihood that the data X have been generated from the given
% parameters (mu, sigma) of the one-dimensional normal distribution.
% TODO fill out this function
res = exp(-(x-mu)^2/(sigma*2))/sqrt(2*pi*sigma); |
function X = TDMAsolver(A,B,C,D)
% NOTE:A_1 = 0, C_n = 0
Cp = C;
Dp = D;
n = length(A);
X = zeros(n,1);
% Performs Gaussian elimination
Cp(1) = C(1)/B(1);
Dp(1) = D(1)/B(1);
for i = 2:n
Cp(i) = C(i)/(B(i)-Cp(i-1)*A(i));
Dp(i) = (D(i)-Dp(i-1)*A(i))/(B(i)-Cp(i-1)*A(i));
end
% Backward substitution... |
% Create diaries based on the start and endtime of the PSG recordings.
clear all; close all; clc;
% Add path to actant scripts.
addpath(genpath('/Users/me/Code/matlab/actant/'));
addpath(genpath('/Users/me/Code/matlab/psgGeneactivActiwatch/'));
% Define paths.
PSG_INPUT_FOLDER = '/Users/me/Data/projectx/psg/';
... |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% _ _ _ %
% | | __ _ _ __ ___ | |__ _-(")- %
% | | / _` | '_ ` _ \| '_ \ `%%%%% %
% | |__| (_| | | | |_| | |_) | _ // \\ %
% |_____\__,_|_| |_| |_|_.__/_| |__ ___ %
% | | / _` | '_ \/ __| %
% ... |
function dh = entr_n(d,Lmax)
n=length(d);
n_letters = 2;
h=zeros(1,Lmax);
lmax=Lmax+1;
for j=1:lmax
nw=2^j;
cnt=zeros(1,nw);
% generate dictionary
C = cell(1, j);
[C{:}] = ndgrid(0:n_letters - 1);
C = reshape(cat(j+1, C{:}), [], j);
C=int8(C);
n1=n-mod(n,j);
zk = reshape(d(1:n1), j, []);
m=length... |
function [ D_S, D_T ] = getDataClass( params )
% This function generates a synthetic dataset for domain adaptation
% according to the causal DAG: D --> X_C --> Y --> X_E
% output: source (D_S) and target (D_T) data in the format [X_C; Y; X_E],
% i.e. (3 x n_S) and (3 x n_T respectively)
% number of source an... |
% Analyzes data from the BCI2000 P3 spelling paradigm
%
% (1) data has to be converted to a Matlab .mat file using BCI2ASCII
% IMPORTANT: Set "Increment trial # if state" to "Flashing" and "1"
%
% (2) call this function
% syntax: [res1ch, res2ch, ressqch] = p3(subject, samplefreq, channel, triallength,
% ... |
%Solve the Household problem with borrowing constraint
%using Coleman Policy iteration
clear
global beta r bbar a y a_grid policy_guess M j;
beta = 0.96; %discount
bbar = 0; %-0.01; %borrowing constraint
r = 0.02; %interest rate
%Stochasticity parameters
epsilon = 0.15;
y_H = 1 + epsilon;
y_L = 1 - epsilon;... |
% function that computes the release prob-ty (p_v) and its error (err) for the MCell
% simultions
% input: "folder_path" contains the path to the foldres with Mcell results.
function [p_v, err]=pv_and_err(folder_path)
s=dir(folder_path);
num_fold=length(s); % number of subfolders
cd(folder_path) % move to the f... |
function [cleanimg,boundarywidth] = cleanUsingDensity(img,p_densitythreshold,windowwidth)
width = size(img,2);
height = size(img,1);
colordepth = size(img,3);
p_blackthreshold = 20;
p_centerdensitythreshold =.2;
p_windowsize = windowwidth;
density = calculateDensity(img,p_blackthreshold,p_windowsize);
clearmatrix = ... |
function [] = CreateNoisyWAV(Frequency, Coherence, Duration, SampleRate, Filename)
%Generates a sine wave, hides it in white noise and converts to audio WAV file.
% Frquency in Hz
% Duration in ms
% Sample Rate in Hz
%Converting Duration from ms to seconds (because Hz is used as units in frequency and sampl... |
function [respTrain, targTrain, ...
respTest, targTest ...
]=loadE4()
%% Load data from Experiment 4
% 4.17.2015-Created
%% Experiment
y = tdfread('data/Exp4.txt');
delays = [0 7 14 28];
answers = [1343 4734 10589 2606 5576 931 7333 3634 6240 ...
4409 1331 1026 8288 6402 9966 1064 5834 7524 ...
4386 ... |
function fn_sliderenhance(hu,varargin)
% function fn_sliderenhance(sliderhandle)
%---
% allows a slider uicontrol to evaluate its callback during scrolling
% (instead of only at the moment that the mouse if released)
% just call 'fn_sliderenhance(sliderhandle)' once
%
% notes:
% - the function sets a 'WindowButtonDown... |
function plotPath(pathC,kC,nGoalB,K,jointLimits,showConfigSpace,legNum)
%Plots a path in the Cartesian space, referenced to the rover's body
%coordinate frame.
axis([-1.5 1.5 -1.5 1.5 -1.5 0.5]);
xlabel('x [m]');
ylabel('y [m]');
zlabel('z [m]');
hold on
%Plot the pat... |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DFBAlab: Dynamic Flux Balance Analysis laboratory %
% Process Systems Engineering Laboratory, Cambridge, MA, USA %
% July 2014 %
% Written by... |
function [triangleQuality, bestAnchors] = findAnchorTriangle(t, nodeID, penalty)
%[triangleQuality, bestAnchors] = findAnchorTriangle(t, nodeID,<penalty>)
%
%This function finds the three anchors that are best for a certain node.
%
%To do this, it tries all combinations of triangles. and tests them for
%whether t... |
function varargout = GLW_splitfiles(varargin)
% GLW_SPLITFILES MATLAB code for GLW_splitfiles.fig
%
% Author :
% Andr Mouraux
% Institute of Neurosciences (IONS)
% Universit catholique de louvain (UCL)
% Belgium
%
% Contact : andre.mouraux@uclouvain.be
% This function is part of Letswave 5
% See http://nocions.webn... |
function [pairlist, psyphycell, mdl] = sigmoidfit_TT(cellname,fitt, varargin)
%
% Fits the choice patterns with a sigmoid normcdf(x,x0,w), and returns
% psyphycell, a matrix that contains one row for each juice pair:
% psyphycell(pair,:) = [fittedmodel.x0, fittedmodel.w, Rsq]
% The fit is done in the space of number r... |
classdef OpenLoop<Engine
%
% OpenLoop model models agents over an input biofilm cell density.
% That is, agents do not affect biofilm cell density, instead
% it is input as a variable and should be the measured cell densities
% in each frame of the experimental data
%
properties
start_density... |
close all
clearvars
N = 1000;
sigma_e = 1;
sigma_v = 4;
b = 20;
[u] = func_generateU(N);
[y,x] = func_generateY(u, sigma_e, sigma_v, b);
figure
plot(u)
hold on
plot(y)
% State space equation definition
A = [1 0; 0 1];
Re = [sigma_e 0; 0 0.01]; % Hiden state noise covariance matrix
Rw = sigma_v; % Observation varianc... |
function sliderDemo
f = figure(1);
global p
%// initialize the slider
h = uicontrol(...
'parent' , f,...
'units' , 'normalized',... %// pixels settings
'style' , 'slider',...
'position', [0.05 0.05 0.9 0.05],...
'min' , 1,... ... |
function pred_p_yy = pred_cov_yy(psu_sigma,pred_mes,n,k)
pred_p_yy = zeros(8,8);
for i=2 : 17
pred_p_yy = pred_p_yy + 0.5 * (psu_sigma(:,i)-pred_mes)*(psu_sigma(:,i)-pred_mes)';
end
pred_p_yy = (pred_p_yy + k * (psu_sigma(:,1)-pred_mes)*(psu_sigma(:,1)-pred_mes)') / (n+k);
end |
function outputArg1 = Logistic(pict)
%LOGISTIC 此处显示有关此函数的摘要
% 此处显示详细说明
[M,N]=size(pict)
x=0.334;
u=3.89;
for i=1:2000
x=u*x*(1-x)
end
A=zeros(1,M*N);
A(1)=x;
for i=1:M*N-1
A(i+1)=u*A(i)*(1-A(i));
end
B=uint8(255*A)
mapping=reshape(B,M,N)
subplot(2,2,1)
imshow(mapping)
out=bitxor(pict,mapping)
v=out
subp... |
function [Flatf, Mlatf] = lateral_load(SIM, hcm)
d = 0;
Rc = hcm.Rcr;
if (SIM.front_rear == 0)
d = 2;
Rc = hcm.Rcf;
end
Mlatf = SIM.Alat*hcm.Msloc(1 + d)*2*(hcm.Hcgs - Rc);
Fu = (2*SIM.Alat*hcm.Muloc(1 + d)*hcm.Hcgu)/hcm.Lcw;
Flatf = (Fu + SIM.Alat*hcm.Msloc(1 + d... |
function [trainset, testset] = splitData(images, eyesPos, looksInfo, ratio)
n = length(images);
nPerm = randperm(n);
imagesRand = images(:, :, nPerm);
eyesRand = eyesPos(nPerm, :);
looksRand = looksInfo(nPerm);
split = round(ratio * n / 100);
trainset = { imagesRand(:, :, 1:split), eyesR... |
function ShowUnshiftedQR()
% function ShowUnshiftedQR()
% Illustrates the unshifted QR algorithm applied to the upper Hessenberg
% matrix. A Call of the form ShowUnshiftedQR() uses a random 5x5
% example.
% GVL4: Section 7.3.3
n = 5;
H0 = hess(randn(n,n));
H = H0;
Q = eye(n,n);
for k=1:100
[H,Q] = H... |
% This is an example of how to use weighted NMF on data with missing values.
clear
% load data
% suppose the current folder is the one containing the NMF toolbox
load('.\data\ALLAML.mat','classes012','D');
classes=classes012;
clear('classes012');
% simulate missing values
D(rand(size(D))<0.05)=NaN;
k=3; ... |
display('Hello Richard')
disp('HELLO ANTONIO!')
|
clear;
d=2;
N_large = 28;
N_small = 14;
%Load training data
training_images = loadMNISTImages('data/train-images-idx3-ubyte');
training_labels = loadMNISTLabels('data/train-labels-idx1-ubyte');
SAMPLE_NO = size(training_images,2);
%Store images in cell, original and downsampled
training_images_cell = cell(1, SAMPLE... |
% EJERCICIOS RESUELTOS DE VISIÓN POR COMPUTADOR
% Autores: Gonzalo Pajares y Jesús Manuel de la Cruz
% Copyright RA-MA, 2007
% Ejercicio 8.14: Descripción de contornos, regiones y superficies 3D
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 8.5.7 Superficies 3D: curvatura de super... |
function [errorCode, errorMsg,cancelNo] = BatchEntrustsCancel(connection,token, batchNo)
% EntrustCancel 通过Type来指定不同标的:
%[errorCode, errorMsg,cancelNo] = BatchEntrustsCancel(connection,token, batchNo)
import com.hundsun.esb.* com.hundsun.esb.data.*;
[errorCode, errorMsg,packet] = CallService(connection,Make... |
function [ y ] = reaction1( V , U , epsilon )
%UNTITLED8 Summary of this function goes here
% this is the reaction term of V
b = 1.9;
c = 0.1*2.54;
y = 0;
y = b*U-c*V;
end
|
%
% Placement
% Function to place the matrices into the position
% to get the matrix form of the DataMatrix
%
% Input
% Msg : message
% size : size of the matrix
%
% Output
% DM : matrix form of the DataMatrix
function DM = Placement(Msg, size)
% Initialization of the matrix
DM = ones(size)*5;
% Start posi... |
function r=tign2ros(p,i)
dxlon=(p.fxlong(3:end,2:end-1,i)-p.fxlong(1:end-2,2:end-1,i));
dxlat=(p.fxlat(3:end,2:end-1,i)-p.fxlat(1:end-2,2:end-1,i));
dx=sqrt(dxlon.^2+dxlat.^2);
gx=(p.tign_g(3:end,2:end-1,i)-p.tign_g(1:end-2,2:end-1,i))./dx;
dylon=(p.fxlong(2:end-1,3:end,i)-p.fxlong(2:end-1,1:end-2,i));
dylat=(p.fxlat(2... |
Radius = 200;
for i=1:1
if (i==1)
figure('name','Path');
end
grid on;
set(gca,'XLim',[-225,225]);
set(gca,'YLim',[-225,225]);
xlabel('x(cm)','FontSize',18)
ylabel('y(cm)','FontSize',18)
ax = gca;
ax.FontSize = 18;
circle1=zeros(81,1);
circle2=zeros(81... |
%% SNAKE SEGMENTATION W/O EDGES
% W.Opoczynski 2017-12
% Implementacja algorytmu segmentacji aktywnego konturu "snake"
% na GPU przy uzyciu parallel computing toolbox
%
% segmentedImage = localizedSegParallelGPU(parameters)
%
% @param object parameters {
% array image
% array initMask
% OPTIONAL parameters
% int ma... |
function cell_data = sideToCell(sideX,sideY)
% Converts cell data to side data using linear interpolation
% Inputs:
% sideX : x-side data
% sideY : y-side data
% Outputs:
% cell_data : vector valued cell-centered data.
[~,Ny] = size(sideY);
[Nx,~] = size(sideX);
cell_data = zeros(Nx,Ny,2);
cell_data(:,:,1) = 0.5*... |
%Read the image 'chess.jpg'. This image is supplied by MATLAB. (show your code)
img_chess = imread('chess.jpg');
grayImg = rgb2gray(img_chess);
%Compute the edge map of the image using the Canny algorithm with the MATLAB default parameters. (show your code)
bw = edge(grayImg,'canny');
%Apply hough transform
[H,theta,rh... |
function createReplaceTagsLayout(tab)
latestHED = 'HED 2.026';
remap = '';
tags = '';
output = '';
header = true;
columns = '';
remapCtrl = '';
tagsCtrl = '';
outputCtrl = '';
createPanel(tab);
function browseOutputCallback(src, eventdata, replaceOutputCtrl, ...
myTitle) %#ok<INUSL>
% Callback ... |
function [J, grad] = costFunctionReg(theta, X, y, lambda)
%COSTFUNCTIONREG Compute cost and gradient for logistic regression with regularization
% J = COSTFUNCTIONREG(theta, X, y, lambda) computes the cost of using
% theta as the parameter for regularized logistic regression and the
% gradient of the cost w.r.t. ... |
function [accuracy, loss] = ComputeAccuracyAndLoss(W, b, data, labels)
% [accuracy, loss] = ComputeAccuracyAndLoss(W, b, X, Y) computes the networks
% classification accuracy and cross entropy loss with respect to the data samples
% and ground truth labels provided in 'data' and labels'. The function should return
% th... |
function valor = my_montecarloHitMiss(f,a,b,m)
x = (b-a).*rand(m,1) + a;
y = (b-a).*rand(m,1) + a;
k = 0;
for i = 1:m
if f(x(i),y(i)) <= 1
k = k+1;
end
end
valor = (b-a)*2*k/m;
end
|
function [J,K,KI,KII,Direction]=PlotKorJ(saveto,E,offset,pp)
% fole ris the folder where all the data is vaed
% E is the elasric modulus or the stifness tensor in Pa
% offset: is when abaqus consider your data in meters or standard SI units
% and your data is actually in mm (offset = 1000) or nm (offest = 1e6) or
% in ... |
function plotSweepRespMean(responses, kernelTimes)
[nRoi, nStim, x , y] = size(responses);
kernelTimesPatch = [kernelTimes, fliplr(kernelTimes)]';
res=permute(squeeze(responses),[2 3 1]);
resp=reshape(res,[x,nStim*y]);
kernel = nanmean(resp, 1);
std_kernel=nanstd(resp,1);
kerneltimes=[];
for k=1:nStim
kernelti... |
%y = -10:0.05:10;
%x = (-10:0.05:10)';
%n = 1;
%{
while n<402
x(:,n) = (-10:0.05:10)';
y(n,:) = -10:0.05:10;
n=n+1;
end
%}
%z = x' + 1i.*y';
%k = x.^2 + y.^2;
%Phi = z +1./z + i*2.0*log(z);
theta = 0:0.01:2*pi;
F = @(z) z + 1./(z);
k = exp(1i.*theta) + 0.1i;
w = F(k);
figure
grid on
plot(w);
%Phi = z +1./... |
function [out] = fisher_z_calculate( in )
out = 0.5 * log( (1 + in ) ./ ( 1 - in ) );
end |
%% Stelling 15
%
% Bij een Matlab plot is de x-as standaard
% positief naar rechts.
%
Antwoord = 1;
|
function PopPlotSingleCellDec(resdec,varname,Xvar,Yvar)
if nargin < 2
varname = 'SpatialInfoPerSpike';%'SSI';
Xvar = 'avedec';%'_traj';
Yvar = 'avedecCross';
end
probestr = {'CA1','V1'};
gainstr = {'low gain','medium gain','high gain','All'};
outcomestr = {'error','All','Correct'};
for iprobe = 1:2
good... |
%% Clear
clear classes;%#ok
%%
distN = 100; % The number of sarcomeres over which to measure the propagation speed.
Tfinal = 10000;
dt = .01;
t = 0:dt:Tfinal;
usenoise = false;
%% General
% minV = -20; %[mV]
%% Crunch
base = fullfile(KerMor.App.DataDirectory,'musclefibre','propagationspeed');
tag = sprintf('N%d_T%d_d... |
function mainTestNAV1
%matlab导航模块的getting start,四元数实验
clear all;
close all;
addpath('D:\Documents\MATLAB\Examples\R2019b\shared_positioning\QuaternionExample\')
dr = HelperDrawRotation;
dr.drawTeapotRotations;
figure;
dr.draw3DOrientation(gca, [1/3 2/3 2/3], 30);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%... |
function I = addcomment(fid, s)
fprintf(fid, '\n// %s\n', s);
end
|
classdef DataPackage < Package
% ======================= CONSTRUCTOR =======================
methods
function obj = DataPackage(data, dsample, taxis)
obj.dsample = dsample;
obj.taxis = taxis;
% combine higher dimension into batch-axis if necessary
expdim... |
function [ trap, simp, time ] = integrals( a, b, n, f )
%[ TRAP, SIMP ] = INTEGRALS( A, B, N, F )
% Input: Value, a, which represents the lower bound and value, b, which
% represents upper bound. N represents the number of subintervals on the
% [a,b] domain. Finally, f, is the function that will be evaluated ... |
function res = PL_WaitForServer(s, wait_time);
% res = PL_WaitForServer - wait until the server signals that it had
% just received new data
%
% res = PL_WaitForServer(s, wait_time)
%
% Input:
% s - server reference (see PL_Init)
% wait_time - 1 by 1 matrix, wait time in milliseconds
% (maximum tim... |
%{
Author: Ravinder Singh and Andy Schreier
E-Mail: {ravinder.singh},{andy.schreier}@eng.ox.ac.uk
Copyright: optical wireless communication group
Status: alpha-testing
Version: 0.1
Versionupdate: 19/02/2020
The given script represents a mini introduction in the initalisation and
steering of the Optotune dual-... |
function y = clusterSignals(in_sound,checking_rng)
out_sound = in_sound;
status = 0;
j = 1;
i = 1;
while i <= length(in_sound)
if(in_sound(i) == 1)
while( j <= checking_rng && ((i+j) <= length(in_sound)))
if(in_sound(i+j) == 1)
status = 1;... |
function varargout = proyecto1(varargin)
% PROYECTO1 MATLAB code for proyecto1.fig
% PROYECTO1, by itself, creates a new PROYECTO1 or raises the existing
% singleton*.
%
% H = PROYECTO1 returns the handle to a new PROYECTO1 or the handle to
% the existing singleton*.
%
% PROYECTO1('CALLBACK',hO... |
function [ ] = plot_traj( registre,Nb_trames )
% Fonction permettant l'affichage de l'avion.
MER_LON = -0.710648; % Longitude de l'aéroport de Mérignac
MER_LAT = 44.836316; % Latitude de l'aéroport de Mérignac
% On affiche l'aéroport de Mérignac sur la carte
plot(MER_LON,MER_LAT,'.r','MarkerSize',20);
text(MER_LON+0... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.