text
stringlengths
8
6.12M
clear all close all res =[256 256 256]; spacing = 320/256; %inputs to mimics frames = 15; % Load in mask data mask_name = 'RV_grayvalues.txt'; mask = zeros(size(image)); [xM,yM,zM,intensity] = textread(mask_name,'%f,%f,%f,%f'); xM = (xM/spacing)+1; yM = abs((yM/spacing)-256); zM = abs((zM/spacing)-256)...
function [csum] = myBin_per_Ares(I, A) % h = imhist(I); %plot(h); csum = cumsum(h); lambda = find(csum>A,1); BW = I > lambda; imshow(BW,[]); %plot(csum); end
tic; times_sim = 5e6; mu = 1000; assembly_life = exprnd(mu, times_sim, 5); route_1 = min(assembly_life(:, [1 2]), [ ], 2); route_2 = min(assembly_life(:, [3 4]), [ ], 2); route_3 = min(assembly_life(:, [1 4 5]), [ ], 2); route_4 = min(assembly_life(:, [2 3 5]), [ ], 2); mean_life = mean(max([route_1, route_...
function [ curve, x ] = maxECcurve( maxima, alpha_percentile, increm ) % maxECcurve( maxima ) estimates the tail of the EC curve from the % distribution of observed maxima over many iid iterations %-------------------------------------------------------------------------- % ARGUMENTS % Mandatory % maxima % alpha_perc...
function y=trz(a) y=eye(4); y(3,4)=a; end
%%% Field length estimation % Updated 12/5/2015 JRG % http://www.aerospaceweb.org/question/performance/q0088.shtml function [FAR_dist] = TO_length_est(parameters) W0 = parameters.W0; %[lb] T0 = parameters.T0; %[lb] Sref = parameters.Sref*0.09290304; %[m^2] cWing = parameters.cWing*0.3048; %[m] Dfus = parameters.Dfus*...
clear all colormap jet %%% settings %%% N = 20; % oscillators placed along one dimension of the grid Nn = N^2; % total number of oscillators levels = 20; dt = 1e-2; % integration time step t_sim = 1; % simulation ti...
function [P, X] = vaCurrent(barOffset, params) %% Vernier acuity experiment on cone absorptions % % Testing if people can see the difference between two cases: % 1) A straight line % 2) Two straight lines barOffset pixels apart % % Vernier acuity in human shows the positional acuity is around 6 sec of % ...
function varargout = workloop(varargin) % function [lennorm,worktot,workpos,workneg,workposact,worknegact,work] = workloop(t, x,y, fmus, act, opts...) % or workloop(t, xl,yl,fmusl,actl, xr,yr,fmusr,actr, opts...) % or workloop(t, xl,yl,ul,vl, fmusl,actl, xr,yr,ur,vr, fmusr,actr, opts...) opt.ordlen = 1...
%MLS_OCCLUDE_INTERPOLATE --- Combination interpolation-mls while invalidating % occluded sections % INPUTS: % point_cloud Point Cloud data to interpolate % x_limit maximum dimension for x-axis % y_limit maximum dimension for y-axis % h guassian parameter for mls function resu...
%% Storage procedure % Storage procedure for this pupil still is simple. for vvv = 1:NumberOfVariables switch vvv case 1; temp = Code; case 2; temp = i; case 3; temp = ii; % within trial case 4; temp = Trial...
function retval = find_best_split (rows,labels) best_gain = 0; best_featue=NaN; best_value=NaN; t_r={}; f_r={}; current_uncertainity = gini(rows,labels); n_features = length(rows)-1; for i=1:n_features col = rows{i}; values = intersect(col,col); for j=1:length(values) true_rows = {}; ...
% sieve of Erasthotenes third version max = 10000; % limit for the max prime number if (nargin > 0) max = int64(str2num(argv(){1})); end tic(); p = [1:max]; % vector of integer numbers n = int64(sqrt(max)); % limit for dividers for i = 2:n % remove multipliers of odd numbers if p(i) > 0 % not cleared yet p...
function [width, length] = rectangle(x) width = x/sqrt(10); length = width * 3; end
function [Svv_channel,Lvj,PSD,Nseg] = cross_spectra(subject, properties) % Authors: % - Deirel Paz Linares % - Eduardo Gonzalez Moreira % - Pedro A. Valdes Sosa % Date: March 16, 2019 % Updates % - Ariosky Areces Gonzalez % Date: January 30, 2021 %% %% Preparing params %% data = subject.MEEG....
% MATLAB code to compute Crank Nicolson for: % U_t = U_xx clear all; clf; close all; clc; % x domain x_min = 0; x_max = 10; dx = 0.1; % Arbitrarily Chosen % t domain coef = 10; % Some relationship between dt/dx^2 to vary delta_t = dx.^2.*coef; t_min = 0; t_max = 2; Nt = (t_max-t_min)/delta_t; % Initial Mesh x = x...
function w = normalEqWithoutBias(Xtrain, Ytrain) a = inv(Xtrain'*Xtrain); b = Xtrain'*Ytrain; w = a*b; end
function ans = your_fcn_name(x) sum(sum(x)); end
classdef Arena < handle %ARENA Arena class modelling an arena % Arena class modelling an arena properties % Simulation parameters simId = 0; % Simulation identifier name = 'defaultArena'; % Arena name (used for movie file) typeName ...
function [] = lotsa_plots(n, m) %%%%%%%%%%%%%%%%%%%%% %%% calculations! %%% %%%%%%%%%%%%%%%%%%%%% tic; % n = 4; m = 1000; % generate matrix of values - lots of columns, n = 4 rows x_m_by_n = normrnd(0,1,n,m); % n rows x m columns % generate mean, variance, and t stat for each column x_bar = ...
function converthitranfile() [filename, pathname] = uigetfile( ... {'*.par','HITRAN files (*.par)'}, ... 'Choose a file...'); [~,~,fileext] = fileparts(filename); if isempty(filename) return elseif strcmp(fileext,'.par') % The file is a *.par file ...
% rewritten for NICO PC, if using MAC, use older version function [keys RT k] = qkeys(startTime,dur,deviceNumber) % If dur==-1, terminates after first keypress myStart = GetSecs; if IsOSX KbQueueCreate(deviceNumber); KbQueueStart(); if dur == -1 while 1 [k.pressed, k.firstPress, k.fir...
function fname = uigetfilename() options.Resize='on'; options.WindowStyle='normal'; options.Interpreter='none'; prompt = 'Enter file ending:'; name = 'File Name'; numlines = 1; defaultanswer = {'_0'}; fname=inputdlg(prompt,name,numlines,defaultanswer,options); end
function trialseq = ALTS_backend(settings,trialseq,id) % SHORTCUTS FC = settings.layout.color.fixation; OW = settings.screen.outwindow; owd = settings.screen.outwindowdims; % INTRO ALTS_intro(settings, trialseq, 1); % Randomly assign to slow/fast haptic nov if rand >= .5; trialseq(:,id.haptic_id) = 1; else trialseq(...
function varargout = symcmap(cmap0,ctr,nsteps) if (nargin < 3), nsteps = Inf; if (nargin < 2), ctr = 0; end; end; if ctr > 1 error('ctr parameter is a fraction < 1'); end if (isnumeric(cmap0) && (size(cmap0,1) ~= 3)), error('cmap can only have three entries.'); end; if (ischar(cmap0)), ...
function [ X,k ] = Gseid( A, b, X0, eps ) %GSeid Iteration D = diag(diag(A));%Get diag(A) L = -tril(A, -1);%Get -L U = -triu(A, 1);%Get -U B = D \ (L + U); %Get Bg f = D \ b; %Get fg X = B * X0 + f;%First iteration k = 1; %Start Iteration while norm(X - X0) >= eps X0 = X; X = B * X0 + f; k = k + 1; end
function [event event_idx event_common_idx] = get_event_wordPair() load('SPIC_text.mat'); for i=1:99 event1(i,1) = duet_1(i); event1(i,2) = duet_1(i+1); end for i=1:99 event2(i,1) = duet_2(i); event2(i,2) = duet_2(i+1); end event = [event1;event2]; event_idx = zeros(size(event)); event_common_idx = z...
% Script for estimating initial parameters % (C) Copyright 2019 The Huang Lab % % All rights reserved Weldon School of Biomedical Engineering % Purdue University % West Lafayette, Indiana % ...
function theta = estimate_GRF_parameters(loc, ind_o, y_o, bins, nu) % Only use 10000 pixels at most for estimation if length(ind_o) > 10000 cap = 10000; else cap = length(ind_o); end % Get positions for estimation ind_o_cap = ind_o(1:cap); loc_o_cap = loc(ind_o_cap,:); %% Make an estimate of t...
function out = test opt = solopt; load HST_tensor.mat load materials.mat load swim_img.mat load tensor_parafac.mat load tensor_tucker.mat % B0= rand(size(A,1), min(size(A,2) - 1, 5)); B0 = rand(size(A)); % Flaw???: No facility to input size of matreces B and C.. m...
% summarize conserved clusters as graph % P1 = vertcat(Pairs_AllClusAllFish{:,1}); % P2 = vertcat(Pairs_AllClusAllFish{:,2}); % Nodes = unique([P1;P2],'rows'); % numNodes = length(Nodes); % % [~,IX1] = ismember(P1,Nodes,'rows'); % [~,IX2] = ismember(P2,Nodes,'rows'); % % G = graph(IX1,IX2); figure;plot(G) % bins = c...
function [distVal,jumpcost] = performMatchingOnComponentImg_Old(testMat,realIndexTest,componentRefImg,ImgRef,testImgRw,testImgCol,technique,featureFunc,avgWidth,heightMatter,testImgPath,imageFiePath_1,testName) distVal = -5; % if(ceil ( (size(ImgRef,2)) * (30/100) ) <= (testImgCol) ) refComponentMat = AnalyzeComponen...
function [c,ptr,cw,ck]=de_2n_code_sub(biny,n,z,ptr) len=length(z); lenw=sum(z); ptrinc=n*len; tem=biny(ptr:ptr+ptrinc-1); ptr=ptr+ptrinc; tem=char(tem+48); tem=reshape(tem,n,len)'; tem=bin2dec(tem)'+1; cw=tem(1:lenw); ck=tem(lenw+1:len); c=separate_inv(z,cw+2^n,ck);
function process_phase_circ_plot(filename_h, amp_range) S = load(['Trials_' filename_h '.mat']); f_num = length(S.Trials); for i = 1:f_num clearvars c_phase F = figure; c_phase = S.Trials(i).Phase(S.Trials(i).Amps>amp_range(1)&S.Trials(i).Amps<amp_range(end)); A = circ_plot(c_phase,'pretty'); set(A,...
function cropImageInfo = batchCropImage(pixel, imfolder, exfolder) % batch cropping image and throw images too small % get image paths imgs = imageDatastore(imfolder,'IncludeSubfolders',true,'FileExtensions','.png','LabelSource','foldernames'); list = []; h = waitbar(0,'Cropping images...'); for i = 1:length(img...
function nFiles=FlylabPlotSpeed(dirspec, filespec) f = gcf; filenames = GetFilenames(dirspec, filespec); nFiles = length(filenames); speedTotal = []; speedAll = []; tAll = []; for i = 1:nFiles filedata = FlylabReadFile(filenames{i}); if (FlylabIsValidFiledata(filedata)) ...
function bgsubtracted = bgsubtract(mov) maxproj = uint8(max(mov,[],3)); bgsubtracted = uint8(zeros(size(mov))); for k = 1:size(mov,3) bgsubtracted(:,:,k) = maxproj - mov(:,:,k); end
function lsFile = trollify(this, varargin) ASSIGN_TSERIES_FORMAT = 'DO %s = %.16g + dzero; \n'; ASSIGN_SCALAR_FORMAT = 'DO %s = %.16g; \n'; STEADY_REF_FILENAME = 'SteadyRef.inp'; TIME_STAMP = datestr(now( )); opt = passvalopt('model.trollify', varargin{:}); switch upper(opt.ParametersAs) case 'EXOGENOUS' ...
function U0=atgetU0(ring) % % computes Energy loss per turn in eV . % %see also: ringpara atsetcavity atenergy %S.Liuzzo modified to use atenergy.m [~,~,~,~,U0]=atenergy(ring); return % % emass=510998.928/1e6; % electron mass in MeV % % a = findcells(ring,'Energy'); % if isempty(a); % gamma = 3000/emass; % els...
function [success_status,img, data_buffer]=rad_mat(scanner,runno,input_data,options) % [success_status,img, buffer]=RAD_MAT(scanner,runno,input,options) % Reconstruct All Devices in MATlab % rad_mat, a quasi generic reconstruction/reformating scanner to archive % pipeline. % It relies on a dumpheader perl script which ...
%% Set environment addpath(genpath('nifti_utils')); addpath(genpath('dwmri_visualizer')); data_path = 'data'; %% Volume test % Load data fa_vol = nifti_utils.load_untouch_nii_vol_scaled(fullfile(data_path,'fa.nii.gz'),'double'); mask_vol = nifti_utils.load_untouch_nii_vol_scaled(fullfile(data_path,'mask.nii.gz'),'log...
classdef PaperRaceEnv < handle %PAPERRACEENV Paper Race környezet % Osztály, ami környezetet biztosít a paper race játékhoz. properties TrkPic Trk GGPic SzakLis lepesek = 0 % az eddig megtett lépések száma Szak = 6 % a következő átszakítandó szakasz ...
classdef xmon < sqc.qobj.qubit % % Copyright 2016 Yulin Wu, USTC % mail4ywu@gmail.com/mail4ywu@icloud.com properties aczSettings@sqc.qobj.aczSettings end end
function [X, time] = solve_implicit(A, b) tic [L, R] = Householder_implicit(A); right = Apply_Q(L, b); opts.UT = true; X = linsolve(R,right,opts); time = toc; end
% Parallel_call_function_10000 % This script calls ABC_Algorithm in a parallel way so that the particles % are computed in parallel subsets. %% For loop function Parallel_function_VTD_AbsDist_Modelv5_v1_019() %% %Here we fit a data set that has been simulated with a parameter vector %that we choose. functionname = mfil...
[x,t] = wine_dataset; size(x) size(t) setdemorandstream(391418381) net = patternnet(10); % net.divideFcn='divideblock'; % net.divideParam.trainRatio=75/100; % net.divideParam.valRatio=15/100; % net.divideParam.testRatio=10/100; view(net) [net,tr] = train(net,x,t); nntraintool plotperform(tr) testX = x(:,tr.testInd); t...
classdef MaskFft properties adjoint = 0; maskSize xSize ySize zSize mask end methods function self = MaskFft(mask) % Get original dimensions mask self.maskSize = size(mask); % Put rest of dimensions into zSize [self.xSize, self.ySize, self.zSize] = size(mask); ...
%simple function - looks for missing issue dates function [T,ind]=timefix(time) ind = ~ismember(time,'') & ~ismember(time,'NaT'); time=time(ind); %ind = ~ind; T = datenum(time,'mmm-yyyy');
% initiate variables clearvars; load('QMDA_HW_05.mat'); % A. plot data kernal G & observed data a a function of x % plot initialization figure(1); clf; axis ij; set(gca,'LineWidth',1,'FontSize',14); colormap(flipud(gray)*0.93); hold on; % plot kernal G imagesc(G); colorbar; % figure settings title('Kernal ...
function px_theta = samplePDF(h,w,sp_theta,Sigma) % SAMPLEPDF : sample probability density function % --------------------------------------------------------- % h : scale % w : scale % sp_theta: sample points of theta, cell array {theta1, theta2} % Sigma: standard deviation vector % px_theta: p(x|theta), mesh values ...
addpath('harris') addpath('transformation') vis = 0; readnew = 1; tic for scale = [1,1/2,1/3] if readnew % I1 = imread('images/boat/img1.pgm'); % I1 = imread('images/rescaled/00.jpg'); I1 = imread('images/own/origrot.jpg'); I2 = imread('images/own/rot2.jpg'); I1 = imresize(...
function [trasfData] = tsEvaTransformSeriesToStationaryTrendOnly_ciPercentile( timeStamps, series, timeWindow, percentile, varargin ) disp('computing the trend ...'); [statSeries, trendSeries, filledTimeStamps, filledSeries, nRunMn] = tsEvaDetrendTimeSeries(timeStamps, series, timeWindow, varargin{:}); disp(['computi...
function [PC_back,intmem_back,cycle_back]=DivAB(PC,cycle,intmem) intmem_back=intmem; %load ACC,B ACC=intmem(225,1); B=intmem(241,1); %load PSW PSW=loadPSW(intmem(209,1)); CY=PSW(1,1); AC=PSW(2,1); F0=PSW(3,1); RS1=PSW(4,1); RS0=PSW(5,1); OV=PSW(6,1); UN=PSW(7,1); ...
function myVega = Vega(spot,strike,time,interest,sigma) myExpiry=((169000-aTime)+3600*24*daysact('10-jun-2016', '16-sep-2016'))/(3600*24*252); d1=(log(spot/strike)+(interest+sigma^2/2)*time)/(sigma*sqrt(time)); myVega = spot*sqrt(1)*normProbDensFun(d1);
%% ML % LAB 4, BD: SPAM, Classifier: SVM % April 2016, MC clear close all clc i_plot=1; % 1 plot BD i_lineal=1; % Linear Classifier i_gauss=1; % Gaussian Kernel Classifier %% Loading SPAM Database % load dataspam.txt -a...
function [TarFileName,TarFileNum] = TargetFile(TarPath) TarFilePath = dir([TarPath,'*','.txt']); TarFileNum = 0; for i = 1 : length(TarFilePath) TarFileNum = TarFileNum +1; end TarFileName = cell(TarFileNum,1); for i = 1 : TarFileNum TarFileName{i} = TarFilePath(i).name(1:end-4); end
clc; n = length(lda1); A = nn.A; for i = 1 : n mc1(i, :) = data1(i, :) * log(nn.P0 + eps); mc2(i, :) = data2(i, :) * log(nn.Q0 + eps); end; [p c1] = max(mc1'); [p c2] = max(mc2'); I=log(A./(sum(A')'*sum(A))); I(isnan(I))=0; I=A; for i = 1 : n ILDA(i) = I(lda1(i), lda2(i)); end; [p ilc]=sort(ILDA); for i = 1...
function [A,dA,F,dF,T,dT] = mnlinsinfit(X,Y,F,d) if nargin < 4 d = false; end if size(X,2) > size(X,1), X = X'; end if size(Y,2) > size(Y,1), Y = Y'; end if size(F,2) > size(F,1), F = F'; end if d YS = max(Y); Y = Y/YS; XS = max(X); X = X/XS; F = F*XS; end [A,dA,T,dT] = mlinsinfit(X,Y,F); %#ok<NASGU...
%% Decoding LDPC codes using Sum Product Algorithm clc(); clear all; close all; H = xlsread('H_matrix.xlsx'); % Loading the given H matrix in MATLAB gamma = 3; % Number of 1's in each column of Matrix H rho = 6; % Number of ...
function randomFreqPlot(runType, runNb, windowLen, plotQ) if nargin < 3 windowLen = 4188; end if nargin < 4 plotQ = true; end accX = 0; accY = 0; accZ = 0; gyroX = 0; gyroY = 0; gyroZ = 0; tau = 0; time = 0; if strcmpi(runType, 'U') expFile = sprintf('Experiment...
clear all; close all; % % Digitized data from Gust (Al sample) p.3574 % xax = [[475 5361];[2887 5361]]; yax = [[475 5361];[475 898]]; dat = [[2427 5293];[2231 5217];[2073 5142];[1907 5082];[1779 4923];[1696 4803];... [1651 4599];[1636 4449];[1666 4313];[1636 4185];[1560 4011];[1492 3876];... [1462 3732];[...
function [imRes] = dpnInterpolate(dx) %dpnInterpolate - take the ion image and interpolate it across the empty %rows % First identify the empty / non-empty rows... fx = sum(dx.img,2) == 0; % Create the image subset... imTmp = dx.img(~fx,:); % Resize the image to full size imRes = imresize(imTmp,size(dx.img)); end
classdef dimension < double properties (SetAccess = immutable) name % name of dimension value = 1 % value of dimension in terms of other dimensions dimensions = {} % dimensions degrees % power of each dimension end methods function dim = dimension(name,value) ...
clc;clear; %LOADING DATASET %load GoodMeasurement_14_bus.mat load Dataset_B.mat; %HERE COME USER-DEFINED PARAMETERS OF GN algorithm (using default options is recommended) eps_tol=10^-5; %stopping criterion for max(abs(delta_x)) Max_iter=100; %maximum number of GN iterations H_decoupled=0; %use full Jacobian m...
function y = event_gradient(t,y,k2,thresh,component) %when the L2 norm of the gradient field is below thresh, the returned y is true, otherwise false. %note that y is in Fourier space. %L2 norm of the gradient field is \int_{|| \nabla y(x) ||^2 dx} = \int_{|| k ||^2 ||y(k)||^2 dk} %k2 should correspond to each ...
%% ---------------- Send audio ------------------- close all; clear all; clc; % connect to tcp/ip server server_ip = 'localhost'; portNum = 10000; % create tcp/ip obj t = tcpi p(server_ip, portNum); t.OutputBufferSize = 512; t.ByteOrder = 'littleEndian'; fprintf('Connecting to server ...\n') fopen(t); %% flushoutp...
%% Stelling 13 % % Als BT-er gebruik je zowel standaard functies als zelf % gemaakte functies. % Antwoord = NaN; % vul hier het juiste antwoord in 1 (WAAR) of 0 (ONWAAR)
% goal: fix h, plot N for different delta % cd into folder with csv data from paraview cd ~/Dropbox/FEniCSproj/Ndelta/tests_2D/DiagonalData/ files = dir('2D_adr_h1_20*_u.csv'); a = files(1).name; = getnames(a); aaa = getvalues(a); b = files(2).name; bb = getnames(b); bbb = c = files(3).name; cc = get names(c); %% ...
function flag = IsInPolygon(x,y,X1,Y1,X2,Y2,X3,Y3,X4,Y4,X5,Y5,X6,Y6,X7,Y7,X8,Y8,X9,Y9) if (inpolygon(x,y,X1,Y1) || inpolygon(x,y,X2,Y2)|| inpolygon(x,y,X3,Y3)||... inpolygon(x,y,X4,Y4)|| inpolygon(x,y,X5,Y5) || inpolygon(x,y,X6,Y6)||... inpolygon(x,y,X7,Y7) || inpolygon(x,y,X8,Y8) || inpolygon(x,y,X9,Y9)) ...
function [X1] = SolveSODERK4(h, u, X0) % This function solves the forward nonlinear differential equations of the % onewheel using a fourth order Runge-Kutta method. % The function arguments are the initial conditions, input and stepsize h % The function output is the new calculated state % Define model constants M = 1...
function [b, sig, likes, accept_rat] = mcmc_nmr_bsig (Dk, T2ML, z, n, Niter, stepsize, figureson) if nargin < 5 if nargin < 4 Niter = 1e6; end stepsize = 0.8; end kk = log10(Dk); % set bounds on each parameter maxlogb = inf; minlogb = -inf; minsig = 1e-5...
z_count =1; load('regress_0kg.mat') for count = 1:y_count-1 z_kg_acc(z_count,1) = y_kg_acc(count,1); z_kg_vel(z_count,1) = y_kg_vel(count,1); z_kg_theta(z_count,1) = y_kg_theta(count,1); z_mass(z_count,1) = y_mass; z_kg_power(z_count,1) = y_kg_power(count,1); z_count = z_count+1; end load('reg...
function [ad,v1,x1,y1,Fl1,Fd1,Nr1,Nf1,T_d1,X_d,p]=FindDeccelerationVectors1(a,v,T_d,x,y,Fl,Fd,Nr,Nf,Va,Straight_Line,k,m,p,dt,beta,Sr,X_d,Vec_p,M,c,b,L,H,Miu,Miur,Miuf,R,A,Cd,Cl,Ro_air,g,Start_ratio,Gr,Final_ratio,T1,T2,T3,T4); ad=[a(1:p)]; v1=[v(1:p)]; T_d1=[T_d(1:p)]; x1=[x(1:p)]; y1=[y(1:p)]; Fl1=[Fl(1:p)]; Fd1=[Fd...
load ('g149novickA.mat') time=0:0.1:10; tau1=1; tau2=2; tau3=3.55; tau4=4; x=data(:,1); y=data(:,2); V1=1-exp(-time/tau1); V2=1-exp(-time/tau2); V3=1-exp(-time/tau3); V4=1-exp(-time/tau4); plot(x,y,'bx',time,V1,'g-',time,V2,'r-',time,V3,'c-',time,V4,'m-'), xlabel('time'),ylabel('Enzyme Activity'), legend('data','V1','V...
clc; clear all; x = [-10:0.1:10].'; y = 3*x.^4 + 2*x.^3 + 7*x.^2 + 2*x + ones(size(x))*9; plot(x, y); title("Polynomial");
function transmitter( packet, fc ) %% TRANSMITTER FUNCTION % Group 13 % Introduction to Communication Engineering. September 2015 % % Implementation of the receiver. % INPUT: packet - vector with data % fc - carrier frequency % % OUTPUT: SOUND to the speaker ...
function unique_cycles = remove_duplicate_cycles(cycles) % Removes duplicate cycles from <cycles> (mxn string array where % m is the number of cycles and n is the number of nodes per cycle) % Use to clean the output from find_perfect_5cycles because it finds % duplicates [~, unique_row_idxs] = uniqu...
%% Set up input file and set file properties file_path = 'C:\Users\Ali\Documents\ISML\MEA Data\20170622_400_0\'; lfs_stim_frq = [0,1, 0.5, 0.33, 1, 1, 1, 0.33, 0.33, 0.33, 0, 0]; lfs_file_num = [33,34,37,40, 60,62,65,72,74,76, 73,75, 35,74]; file = 3; file_name = ['data' num2str(lfs_file_num(file),'%04i') '.mcd']; ...
function [AN,FN] = reduce_global_matrix(model,model_data,d) mu = get_mu(model); model.decomp_mode = 1; [A,r] = model.operators(model,model_data); model.decomp_mode = 2; [Acoeff,rcoeff] = model.operators(model,model_data); A1_diff = Acoeff{2}(1)*A{2}{1}; A1_adv = Acoeff{2}(3)*A{2}{3}; A1_dir = Acoeff{2}(5)*A{2}{5}; ...
function [p] = singlePro(time,active,inactive) %% Calculate single probability % % Input % time: date vector % Matrix active: entry 1 when alarm gets active % Matrix inactive: entry 1 when alarm gets inactive % % Output % Array p with probability for each id %% %%%%%%%%%%%%%%%%%%%%%%%%%%% % Preallocate size p = ze...
clc clear all close all format short %%Data mu=398600.2; Re=6378.16; T=100*60; a=((T/(2*pi))^2*mu)^(1/3); alt=a-Re;%km n=1/sqrt(a^3/mu); m_start=100; Isp_chem=200; g0=9.81; tf=T/60; G=[0,0,0;0,0,0;0,0,0;1,0,0;0,1,0;0,0,1]; Gtrans=G'; F=[0,0,0,1,0,0;0,0,0,0,1,0;0,0,0,0,0,1; 3*n^2, 0, 0,0,2*n,0;0,0,0,-2*n,0,0;0,0,-n*n...
function sig = extractSegment(sig, ndxRange) ndxRange(1) = max(1,ndxRange(1)); ndxRange(2) = min(length(sig),ndxRange(2)); sig = sig(ndxRange(1):ndxRange(2));
%displays the ROI function showROIbyRadius(AverageImage,ROI,L, ROI_distances, radius) RASTERFIG = figure('WindowState','maximized'); imshow(rgb2gray(AverageImage));%mat2gray(AverageImage)); %imshow(AverageImage); hold on; colors=['b' 'g' 'r' 'c' 'm' 'y']; for k=1:length(ROI) if ROI_distances(k) <= radius ...
function F = subfnModMedFMIN(W, data) NMed = size(data.M,2); NMod = size(data.V,2); b = W(1:NMed); v = W(NMed+1:NMed+NMod)'; w = W(NMed+NMod+1); const = W(NMed+NMod+2); cP = W(NMed+NMod+3); Y = data.Y; M = data.M; V = data.V; N = length(data.Y); X = data.X; est = X*cP + M*b + V*v + w*((M*b).*(V*v)) + const*ones(N...
function log_modelchar(modelInstance, filepath, currFileEntry, algorithmParam) if isempty(modelInstance) [fileID, errmsg] = fopen(filepath, 'a'); fprintf(fileID,'%s,%s,%s',currFileEntry.subjectString, currFileEntry.exerciseName, ''); fprintf(fileID,'%s','error'); fprintf(fileID, '\n'...
%% CFD Boston University Course ------------------------------------------- % Step 8 of 12 to Navier Stokes Code: Two Dimmensional Burgers Equation % % Governing Equation: % \frac{\partial{u}}{\partial{t}} + u\frac{\partial u}{\partial x} + v\frac{\partial u}{\partial y} = \nu\left(\frac{\partial^2 u}{\partial x^2}+\f...
function newtonSystem(X0,tol) % Input: x0 - initial guess vector % tol - tolerance X_old = X0; k = 1; while( norm(F(X_old))>tol ) Y_new = JF(X_old)\(-F(X_old)'); X_new = X_old+Y_new; fprintf('(x,y) = (%.16f,%.16f) for k=%d\n',X_new(1),X_new(2),k); X_old = X_new;...
function [] = plotbivariate(X,Y,xlab,ylab) % Function to for the plotting of two random variables against each other. % The plot produced is a bivariate scatter graph with two marginal % histograms for both X and Y. % % INPUT: % X = random variable 1 % Y = random variable 2 figure %% Joint distribution ax1 = subplot(4...
function [ reliability] = pso_flc1_costfunction( input_args, z, k ) % function [ sum_reliability, node_reliability ] = pso_flc1_costfunction( input_args, z, k ) %pso_flc1_costfunction pso cost funtion for flc1 % input_args is 1*12 matrix % input_args(1,1:6) cL bL aM cM aH bH for flc1's input z % input_args(1,7:12...
function decision_tree() [attributes, examples, test_examples] = prepare_data('~/ml_data/adult/adult_attr_names', '~/ml_data/adult/sample', '~/ml_data/adult/sample_test'); global SINGLE_NODE_THRESHOLD POSITIVE_VAL SINGLE_NODE_THRESHOLD = 0; POSITIVE_VAL = '>50K'; active_attributes = []; [attr_name, attributes, is_sin...
classdef rls < FixedEpochLearner %RLS learns using recursive least squares properties %cell array containing error covariance matrices for weights of each neuron P G D end methods function f = rls(nn) f@FixedEpochLearner(nn) ...
% Default starting script for Problem 2 clear all; close all; f = @(X) ( (X(1).^2 + X(2) - 11).^2 + (X(1) + X(2).^2 - 7).^2 ); df = @(X) [ (4.*X(1).^3 + 4.*X(1).*X(2) - 42.*X(1) + 2.*X(2).^2 - 14); ... (2.*X(1).^2 - 26.*X(2) - 22 + 4.*X(1).*X(2) + 4.*X(2).^3) ]; d2f = @(X) [ (12.*X(1).^2 + 4.*X(2...
clear close clc %% ************************************************** % DEFINE SIMULATION PARAMETERS % roomDims = [500,500]; % Room dimensions [Lx, Ly, Lz] in meters srcPos = [roomDims(1)/2,roomDims(2)/2]; % Source position [x,y,z] in meters c=3000; % Speed of sound in air simLength ...
b = 2; L = -1; U = 2; % zadane parametry d = [ 0 1 ]; % możliwe cyfry w liczbie indeks = 1; % zmienna do indeksowania wektora liczb for z = [ -1 1 ]; % znak for e = L : 1 : U; % cecha for i = [ 1 2 ]; % pierwsza cyfra ...
function RasterPlot(spikes,color) % plots a raster for a cell array of spike times % INPUTS: % spikes - cell array of spike times % color - the color for the plot hold on; num_trials = length(spikes); for i = 1:num_trials trial = spikes{i}; len_trial = length(trial); for ...
function [ port ] = feeMaogugu( tradeVmat, feeRatio ) % 使用交易额矩阵TradeVmat粗略估算手续费:直接算每天的,累加,没有recursive % [ port ] = feeMaogugu( tradeVmat, feeRatio ) % -------------------- % 程刚,20150524,初版本 %% 前处理:所有手续费率 % 判断类型 if ~isa(tradeVmat, 'TsMatrix') error('本函数只接受TsMatrix类型的tradeVmat'); end % 临时 if ~exist('feeRatio', 'v...
function [x,i] = bisection(a,b,f,tol,maxiter) i = 0; fa = f(a); fb = f(b); if(fa*fb > 0) disp('Error: Invalid bracket!') return end x = a; fx = f(x); while(abs(a-b) > tol && abs(fx) > tol && i < maxiter) x = (a+b)/2; fx = f(x); if(fx*fa < 0) b = x; %fb = fx; else a = x; ...
% University of British Columbia, Vancouver, 2017 % Alex Kyriazis % William Choi % Custom made gradient descent model used to optimize parameters. If you % are going to use this, make sure you have a good understanding of the % parameters and that you correctly set the cost function in the private % folder ...
function decp_data = cp_remove(sig,cp_sig_len,cp_num) recieve_mat = reshape(sig,cp_sig_len,ceil(length(sig)/cp_sig_len)) decp_data = recieve_mat(cp_num+1:cp_sig_len) end
function fxi = f_dim1(f,x,d,x_d) %create 1-dimensional version of a multi-dimensional function %the chosen dimension is d %and the value on that dimension is x_d xx = x; xx(d) = x_d; fxi = f(xx); end