text
stringlengths
8
6.12M
function [hits,results,seqhits,uniquehits] = databaseID_ALL_v1(database,ordseq,taxid,minlength,parent) % load database taxonomy = database.taxonomy; refString = database.string; protein = database.protein; % **TEST** load trio frequency (ONLY 9913 for now) **TEST** % load('singles_9913.mat','tabletters') % patt1 = t...
function [ tau ] = step ( d, z, delta ); a = d'*d; b = 2*(z'*d); c = z'*z - delta^2; tau = (-b + sqrt(b^2 - 4*a*c))/(2*a);
function [metric, output_log, total_steps] = train_diagoasis(images, labels, parms, images_tst, labels_tst) % % % %% checks whether a file with training results for the given variables already exists % if yes (and do_force is 0), then load the file and skip the training. % otherwise, continue to the traini...
function [r, theta] = cart_to_pol_coord(x,y) r=sqrt(x.*x+y.*y); theta=atan2(y,x);
function Psi=getRandomBasisVectors(numRandomBasisVectorsPerDimension,probabilityInfo) % Hugo Esquivel, 2021 % - % Remark: % - For simplicity, a full tensor product is used below to get the required random basis over the probability space. numRandomVariables=length(probabilityInfo.name); numRandomBasisVectors=numRandom...
function EEG = oe2eeglab(pathname,filebasename) % % EEG = oe2eeglab(pathname,basefilename) % % Loads open-ephys-format data into EEGLAB structure. % % Inputs: % pathname: the path to the folder where the files are. % filename: any filename up to '.continuous' % % (if no inputs are given, a dialog box wil...
function Problem = ITERmodify_LB_X0_UB(Problem) X0 = Problem.x0(:); LB = Problem.lb(:); UB = Problem.ub(:); XLabels = Problem.XLabels; repeat = true; while repeat disp(' ') BOUNDS = {'Index', 'Parameter'}; for ii = 1:length(X0) BOUNDS{ii+1,1} = ii; BOUNDS{ii+1,2} = XLabels{ii}; ...
function [D,x0,alpha,e_sw,Icr,dIcr] = Ei400_uvw111_at110ver() % simplified verification script, which allows one to check % how do sqw cut works %------------------------------------------------- % Parameters : % data_source= fullfile(pwd,'Data','Fe_ei200.sqw'); bragg = [1,1,0]; % selected bragg % % Cut properties: ...
% clear all % nIND = 2; % nDOF = 16; % PriorID = 18; % DS_rate = 4*1024; % % DS_rate = 1; %% Inference % Truth Kscale = 0.005; K0 = 2; % Sinusodial K_fn = @(x) (sin(2*pi*x) + K0)*Kscale; dK_fn = @(x) 2*pi*cos(2*pi*x)*Kscale; d2K_fn = @(x) -2*pi*2*pi*sin(2*pi*x)*Kscale; % Mixed Gaussian K0 = 1; dnormpdf = @(x,mu,sigm...
function [] = spharmY(l, m, n) % Plots the Yml spherical harmonic. theta=linspace(0, pi, n); phi=linspace(0, 2*pi, 2*n); ct=cos(theta(:)); st=sin(theta(:)); % Evaluate Legendre associated polynomial a=0; a(l+1)=1; P=LegendreP(a,m,ct); g=sqrt((2*l+1)*factorial(l-abs(m))/(4*pi*factorial(l+abs(m)))); rho=g*P*exp(1i*m*phi...
function k = NAND(X1,X2); % NAND gate % 2 layers --> Input and output layer % AND and NOT neural net % ================================================================================================ answer1=[]; fprintf("\n\t----NAND gate----\n\nx1 x2 x1 nand x2\n\n"); for iter=1:4 x1=X1(iter); x2=X...
function [Iex,Iexmask] = esvm_get_seg_icon(models,index,flip,subind,VOCopts) % get the segmentation icon, used to transfer segmentation % % Copyright (C) 2011-12 by Tomasz Malisiewicz % All rights reserved. % % This file is part of the Exemplar-SVM library and is made % available under the terms of the MIT license (s...
% Make new eyeCatch library % find ori_map on eyeCatch webiste, filename: % 'eyeChannelWeightNormalizedpart1.mat' and 'eyeChannelWeightNormalizedpart1.mat' function new_map = interpo_lib(ori_map, downsize) [sampleNumber, oldsize] = size(ori_map); if downsize > sqrt(oldsize) error('Downsize map should be smaller ...
clear all;close all;clc load('x3.mat'); load('t3.mat'); train_i = cat( 1,X(1:40,:),X(51:90,:),X(101:140,:) ); train_t = cat( 1,T(1:40),T(51:90),T(101:140)); M = length(train_t); % # of training examples test_i = cat( 1,X(41:50,:),X(91:100,:),X(141:150,:) ); test_t = cat( 1,T(41:50),T(91:100),T(141:150) ); N = leng...
function lik = q2_loglik(Xtrain, Ytrain, theta) % Computes the log likelihood value for training data (Xtrain, Ytrain) and parameter theta % INPUT % Xtrain : [m x n] matrix, where each row is a n-dimensional input example (assume it % already contains the constant feature set to 1) % Ytrain : [m x 1] v...
function [dx_x1,dx_x2,dy_x1,dy_x2] =... ellipse_coordinates_and_derivatives(ellipse_parameters,n_points,uni) R1 = ellipse_parameters(1); R2 = ellipse_parameters(2); P1 = ellipse_parameters(3); P2 = ellipse_parameters(4); Q1 = ellipse_parameters(5); Q2 = ellipse_parameters(6); N_intervals_x = 3; N_intervals_y = 3;...
function MESH = updateMesh(SIM, MESH, xp, PART) %% =======================================================================% % update the mesh: account for periodic BC on particles, or growing the % mesh if particle cross boundaries % ========================================================================% pad = S...
function y = ShannonEntropy(P) %-------------------------------------------------------------------------- % ShannonEntropy(P) computes the Shannon entropy of a probability distribution P. % % INPUT: % P : array of discrete probabilities % (P can be a row vector of probabilities if a single random % ...
init %% model.type_data = 'Loop_current_kriging'; % model.type_data = 'Gula_kriging'; param_estimated_by_MLE = true; model.grid.dX = 500e3/1024 * [1 1]; model.grid.MX = [1536 512]; % model.grid.MX = [1538 512]; dt = 0.5 *24 *3600; n_x_min = 1; n_y_max = 512; error_obs_h = true; init_model vectname_data = {'zeta'...
classdef Solenoid < handle % Solenoid class % % Properties: % name % length % field % taper % aperture % % Methods: % Track % TrackSpin % GetBField properties name = ''; % string length = 0; % solenoid length in metres ...
function varargout = UIPanel_Selector(varargin) % UIPANEL_SELECTOR MATLAB code for UIPanel_Selector.fig % UIPANEL_SELECTOR, by itself, creates a new UIPANEL_SELECTOR or raises the existing % singleton*. % % H = UIPANEL_SELECTOR returns the handle to a new UIPANEL_SELECTOR or the handle to % the exis...
function [x y theta S slope L ] = mesh_circle(M,r) %UNTITLED2 returns x and y vectors that plot a cirlce % x = r*cos(theta) % y = r*sin(theta) % returns x,y,theta,T-vector,slope of each element,Length of each element theta = 0:2*pi/M:2*pi; % discretization in theta direction x = r*cos(theta); % x-distance x(end) = ...
function [bounds, axis, bins] = bin_generator(bins,varargin) % binstyle='quantile' produces quantile bins and the quantile centers of those bins for the % predicted distribution of stimuli in a Qamar-like experiment. For % instance, bins=3 will produce a vector bounds with points at the % following quantiles [.333 .66...
% clear all; % close all; R = 2; k = 0.1; ke = 5; mr = 5; r = 0.5; mw = 0.5; L = 0.1; %moment bezwladnosci ramienia Jr = 1/3*mr*r*r; %moment bezwładności bez wody J1 = Jr; %moment bezwładności z wodą J2 = Jr + mw * r*r; P1 = 0.9102; I1 = 2.8992e-08; P2 = 0.738385826082795; I2 = 0.004789704258728; W = [P1 I1 0 ...
function makePileBetaMaps(isPC,dirT,nameAna,nSm) nFiles = 16;%64;% rsa_tool_path = 'rsatoolbox'; if isPC==0 based = '/home/smark/fMRI_ana'; spm_path = '/data/smark/spm'; data_path = '/data/smark/fmri_sub_preproc_dir/'; addpath(genpath(fullfile(data_path,rsa_tool_path))) else based = 'C:\Users\smar...
function penalty=atGetPenalty(ConstVal,Constraints) % % Evaluate the penalty function (distance from the target value of every constraint) % vals=cat(2,ConstVal{:}); low=cat(2,Constraints.Min); high=cat(2,Constraints.Max); weight=cat(2,Constraints.Weight); penalty=zeros(size(vals)); toohigh=vals>high; toolow=vals<low...
function result = mInverseJacobiSC( X, M ) %MINVERSEJACOBISC Inverse of the Jacobi function SC. % MINVERSEJACOBISC(X,M) is the inverse of Jacobi function SC for the % elements of argument X and parameter M. X and M must all be real and % the same size or any of them can be scalar. % % See also INVERSEJACOBIS...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% nome_q1d.m %%% Matlab function to detect & sort spikes %%% by Antonio Padilha L. Bo (antonio.plb@lara.unb.br) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [spikeTimesA, spikeTimesB] =...
%------------------------------------------------------------------------ % Fixed parameter controller - Canonical realization + %------------------------------------------------------------------------ global data % some data and time administration data=[]; Je=0; Ju=0; dets=0; % determinis...
clc, clear, close all; fig=openfig('ghoc_impulse.fig','new','invisible'); saveas(fig,'newghoc_impulse.jpg','jpg') close(fig); fig1=openfig('balloon.fig','new','invisible'); saveas(fig1,'newBalloon.jpg','jpg') close(fig1); fig2=openfig('mic_plot.fig','new','invisible'); saveas(fig2,'newMic_plot.jpg','jpg')...
function [x_corr] = filteredspikes_xcorr(data,spikes,params) params.flags.plot_online=0; if params.flags.plot_online==1 plotYN=1; else plotYN=0; end %% choices for strongest channel x_corr.x_corr_radius=[]; channel_index=1:64; %%% 1 choose modal stongest channel for sweep_id=data.sweep_sort.successful_swe...
%1) %Vmall = spm_vol( 'E:\FILER\Lars Jonasson\Belöningsstudie\PT_Sharp\PT_Sharp_A01\wrA01_PT_Sharp'); Vmall = spm_vol( 'E:\FILER\Lars Nyberg\COBRA\COBRA - validering Logan\rc_fPT_rPETsh.nii'); Ymall = spm_read_vols(Vmall(1)); Vmall = Vmall(1); Pstart = Vmall.mat(1:3,1:4)*[1 1 1 1]'; Pend = Vmall.mat(1:3,1:4)*...
pkg load image; img = imread("pratica7.png"); figure, imshow(img); sz = size(img); img = im2double(img); spectre = fft2(img, sz(1) * 2, sz(2) * 2); fourier = fftshift(spectre); #Passo 5 spectre = abs(fourier); #Passo 6 newImg = uint8(spectre); figure, imshow(newImg); filter = zeros...
beam = Beam(Positron); beam.energy = 2.0 * PhysicalUnits.GeV; ncells = 16; drift1 = Drift; drift1.length = 5.00; % metres drift2 = Drift; drift2.length = 6.00; % metres drift3 = Drift; drift3.length = 0.10; % metres drift4 = Drift; drift...
% Get some scalar stuff! function wall_results = quick_results_fpi(fname, state, parse_Ns, parse_Nt, blocksize, tmin, tmax, diag, fold, m_l, noerrors) % Check if we're ignoring error analysis. check_errs = 0; if (exist('noerrors', 'var')) check_errs = noerrors; end if (~strcmp(state, 'ps2')) err...
clear; % 2.2.1 How do the transmitted signalu[k], the (unknown) channel IR-vector h, % and the recorded signaly[k] relate to each other (assuming that noise can % be neglected)? Give a matrix description of this relation (in % the timedomain). This yields an overdetermined system of linear equations, ...
1; c=csvread ("results/out_consolidated.csv" ); csize=size(c(:,2:end))(2); cmean=mean(c(:,2:end),2); sdv=std(c(:,2:end),0,2); confhi=cmean.+(1.960).*sdv./sqrt(csize); conflo=cmean.-(1.960).*sdv./sqrt(csize); csvwrite ("results/out-mean.csv",[c(:,1) cmean(:,1) conflo(:,1) confhi(:,1)]);
%% Create sound: harmonic tone % Copyright (c) 2019, Sijia Zhao. All rights reserved. % Contact: sijia.zhao.10@ucl.ac.uk clear; Fs = 44100; stimDur = 0.5; % in [sec] freqStep = 200; nonComponent = 30; Ns = floor(Fs*stimDur); t = 1/Fs:1/Fs:stimDur; nr = 150; R = sin(linspace(0,pi/2,nr)); R =...
function plotstatsandmetrics(filepath, subjRange) for subjNum = subjRange for mode = 1:4 switch mode case 1 modeText = 'fsconn'; case 2 modeText = 'fscos'; case 3 modeText = 'fullconn'; case 4 ...
function [T, R, d_cell, x1, x2, P1] = rekonstruktion(T1, T2, R1, R2, Korrespondenzen, K) %% Preparation T_cell={T1,T2,T1,T2}; R_cell={R1,R1,R2,R2}; vones = ones(1,size(Korrespondenzen,2)); x1_ = [Korrespondenzen(1,:); Korrespondenzen(2,:);vones]; x2_ = [Korrespondenzen(3,:); Korrespondenzen(4,:)...
function computeDogExtrema(obj) % COMPUTEDOGEXTREMA Compute Difference-of-Gaussian extrema % % Other m-files required: Matcha.m % Subfunctions: none % MAT-files required: none % % Author: Gabriel Moreira % email: gmoreira (at) isr.tecnico.ulisboa.pt % Website: https://www.github.com/gabmoreira/maks...
% produce a summary of the LHq variables by experiment clear all; clc data = readtable('all_variables_4groups_LSW.csv', 'ReadVariableNames', false); groups = {'IE', 'ISS'}; % find the groups for g = 1:length(groups) p = 1; for w = 1:width(data) if strncmp(table2cell(data(1,...
function [competition] = calc_competition(competition_model,B,plants,K,sum_R) %CALC_COMPETITION Calculate the effect of competition on plant per-capita %growth rate. Two models are implemented: 'community-wide', where all %plant species' vegetative biomass (B) contribute to how close the plant %community is to carryin...
function [ shift_im ] = align_edge_ssd( im_ref, im ) %UNTITLED2 Summary of this function goes here % Detailed explanation goes here im_ref = double(im_ref); im = double(im); im_ref_edge = edge(im_ref, 'canny'); im_edge = edge(im, 'canny'); s_range = 30; err = 1000000000; [h, w, c] = s...
% TNM034 - ADVANCED IMAGE PROCESSING % Isabell Jansson isaja187 % Ronja Grosz rongr946 % Christoffer Engelbrektsson chren574 % Jens Jakobsson jenja698 % 2015-12-11 %------------------------------------ function div = DivVal( im ) %Function to calculate the diviation from 1 % If it...
% mxTV. % Version 1.0 28-april-09. % Copyright (c) 2008 by J. Dahl, P.C. Hansen, S.H. Jensen, and T.L. Jensen % % Requires Matlab version 7.5 or later versions. % % These functions accompany the paper % J. Dahl, P.C. Hansen, S.H. Jensen, and T.L Jensen, "Algorithms and % Software for Total Variation Image Re...
function[centers] = mean_shift(points,count,bandwidth,iterations) centers=clusterTranslation(points,count,bandwidth,iterations); centers=floor(centers); end function [ new_set]= clusterTranslation(points ,count,bandwidth,iterations) %figure; %scatter(points(:,1), points(:,2));...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Copyright 2010 - 2015 Moon Express, Inc. % All Rights Reserved. % % PROPRIETARY DATA NOTICE: % The data herein include Proprietary Data and are restricted under the % Data Rights provisions of Lunar CATALYST Space Act Agreement % No. SAAM ID#...
function [ JAMatrix ] = IKinBody( B, M, Tsd, theta0, epsw, epsv ) %UNTITLED Summary of this function goes here % Detailed explanation goes here if(size(theta0, 2) > 1) theta0 = theta0'; end epsilon = 10^-5; if (numel(size(M)) ~= 2 || size(M,1) ~= size(M,2)) disp('M is not a valid transformation matrix either...
%------------- level set for equi affine flow ------ % %------------ initlization ------------------------ % clear ; close all; deltat = 0.2; dt = 0.01; iter = 1000; [x,y] = meshgrid(-3:deltat:3); % t = 0 : deltat: 2 * pi; % x = 3 * cos(t); % y = 2*sin(t)./exp(3*cos(t)/10); %------------ construct signed distance f...
clear clc t=0.005; %initial guess D=3; %fuselage diameter L=0.5; %frame spacing n=50; % number of stringers As=5e-4; b=pi*D/n; %stringer pitch theta=linspace(0,2*pi,n); y=D/2.*sin(theta);% stringer position in y direction x=D/2.*cos(theta); % stringer position in x direction figure (1); plot(x,y,'o'); grid on %% ...
% --------------------------------------------------------------------- % Book: MVA % --------------------------------------------------------------------- % Quantlet: MVAedfnormal % --------------------------------------------------------------------- % Description: MVAedfnormal draws n observations ...
clear; clc; Pos = xlsread('Charging.xlsx'); load Charging.xlsx; Pos(:,2) = 700 - Pos(:,2); Pos(:,4) = 700 - Pos(:,4); Charging_info.posx = Pos(:,1); Charging_info.posy = Pos(:,2); Charging_info.sumcar = 0; Consum_info.posx = Pos(:,3); Consum_info.posx = Pos(:,4); Consum_info.car = Pos(:,5); x = Charging_info.posx(i...
function plotter(gcf, docked) %PLOTTER This function edits figure aesthetics % Set desired properties below newcolors = [53, 79, 254; 255, 83, 0; 15, 200, 154; 146, 0, 239] /255; colororder(newcolors); grid on grid minor box on % Set title, axes labels, and ...
function runsim(sim_options) % set constants used in simulation set_sim_consts; global sim_consts; % Set Random number generators initial state % reset random number generators based on current clock value rand('state',sum(100*clock)); randn('state',sum(100*clock)); % Main simulation loop % Initialize simulation ti...
function R=polyMult(P, Q) m=size(P,2); n=size(Q,2); R=zeros(max(size(P,1), size(Q,1)), m+n-1); for i=1:m for j=1:n k=i+j-1; R(:,k)=R(:,k)+P(:,i).*Q(:,j); end end end
function [U,A, density]=sparse_LSA(X, ReduceDim, lambda, init, g_opts) if isfield(init, 'n_alter') n_alter=init.n_alter; else n_alter=100; end if isfield(init, 'U_tol') U_tol=init.U_tol; else U_tol=1e-2; end if isfield(init, 'A...
function policy=pol_finder(stat) global NO_REPLICATIONS ITERMAX NA NS SMALL TPM TRM for state=1:NS for action=1:NA Q(state,action)=value_finder(state,action,stat.vector) end end for state=1:NS [maxQfactor,index]=max(Q(state,:)); policy(state)=index; ...
function [ flux_vanleer ] = flux_vanleer( qL,qR ) %Function "flux_vanleer" % MATLAB version of Joe Derlaga's "flux_vanleer.f90", % created 070313. % Takes left and right state primitive variables [rho,u,p] and % returns Van Leer FVS flux. global gm1 xg xgm1 xg2m1 % ---------------- %Calculate Left...
% demonstrate matrix operations in matlab (pgs 341-342) a=[3 1 6] b=[4 5 2] c=a-b
function [all_theta] = oneVsAll(X, y, num_labels, lambda) m = size(X, 1); n = size(X, 2); all_theta = zeros(num_labels, n + 1); X = [ones(m, 1) X]; for index = 1 : num_labels theta = zeros(n+1, 1); options = optimset('GradObj', 'on', 'MaxIter', 130); [thetaVal] = fmincg(@(t)(lrCostFunction(t...
function IODist = normIOSelectFrame(ptloc, frames) % function of normalized inter-organelle distance % input: % (1) ptloc: 1 x n or n x 1 structure with a field xy containing point positions and n = % frame numbers % (2) frames: frame indices % output: % normIODist: normalized inter-organelle distances if isempty(f...
function T = dct_init(imsz,blsz) % image size to block size ratio should be integer nch = numel(imsz); T = cell(1,nch); %%create measurements for c = 1:nch D = dctmtx(blsz(c)); Tc = D; for i = 1:(imsz(c)/blsz(c))-1 Tc = blkdiag(Tc,D); end T{c} = single(Tc); end end
function BLOM_SaveDataFile(data, filename, formatstr, default_value) % This function saves a Matlab variable to a data file, in the format % specified by the formatstr argument % Input arguments: % data - the Matlab data to save % filename - the file name to save to % formatstr - a string indicating the data format (...
function [confounds, stats, fd]= legacy_getconfounds(data,filepathM,filepathW,filepathC,TR,HPF,NPC,FDthresh,DetrendOrder,IncludeCensor,Trim,varargin) IncludeAROMA = 0; AROMA = []; if (nargin > 11) IncludeAROMA = varargin{1}; if (IncludeAROMA==1) melodic = varargin{2}; ...
function phi = GF(varargin) % Returns a polytope assert(nargin == 1, 'GF takes one variable'); % Returns a polytope if strcmp(varargin{1}.type, 'inner') || strcmp(varargin{1}.type, 'ap') phi = struct('type', 'inner', 'Op', 'GF', 'args', {varargin}, ... 'formula', strcat('GF(', varargin{1}.formula, ')')); el...
% low pass and then downsampled (will not affect low freq) function [out, fs] = myDownsample(in, n, fs) in = myLPF(in); out = downsample(in,n); fs = fs/n;
% function convert_T_LIDAR_from_txt_to_mat() % converts the lidar time to a mat file. This function is only run once % before running MAIN % open and read the text file %fileID= fopen('ouster_frames_timestamps.txt','r'); a=load("corrected_time.mat"); T_LIDAR = a.time (2:end,:); %tmp_mat = table2array(file(:,1)); %T_L...
% MIT License % % Copyright (c) 2017 JM Joseph % % Permission is hereby granted, free of charge, to any person obtaining a copy % of this software and associated documentation files (the "Software"), to deal % in the Software without restriction, including without limitation the rights % to use, copy, modify, merge, ...
% Example of winning neuron in a SOM (self organising map) % Every neuron is represented as a vector, with synaptic weights from all % neurons that connect to it, plus from the connection to itself (bias) % 3 neurons connected to each other (2 connections each), plus one % connection to itself (bias) making for a tot...
function [celldata, cellpic, ee, err] = Func_Segmentation(MIP,res) % input % MIP = Max intensity image % res = the resolution of MIP % sample name % MAX_12-5-2016 Position2.tif % 'Sample.jpg' I = MIP; figure (1) imshow(I); title('Original Image') % Ajust Brightness I = I -25; I = I*5; bw = imbinarize(I); for i = ...
%path0 = './xp11/'; %path1 = './xp12/' %path2 = './xp13/' %path3 = './xp14/' %path4 = './xp9/' path1 = './xp4/' path2 = './xp5/' path3 = './xp6/' path4 = './xp7/' path5 = './xp8/' path6 = './xp9/' logFile = 'myLog.txt'; string = 'Finished epoch'; y1 = getStat(path1, logFile, string); y2 = getStat(path2, logFile, st...
clear all close all clc x = [-5,10,20;5,-10,-10;5,-20,-20]; x %x = input('Enter the matrix'); [m, n] = size(x); flag = 1; count_n=0; for i = 1:n for j = i+1:n flag = 1; for k = 1:m if x(k,i)<x(k,j) flag = 0; break; ...
% % ITROB2 Robot % global verbose; try % ROB toolbox + Machine vision ! toolboxPath = '..\..\Toolbox\rvctools'; toolboxPath3 = '..\rvctools'; % Verbose verbose = true; % Add subfolders to path addpath(genpath(pwd)); % Load robotics toolbox %mydir = pwd; %cd(toolbo...
function [mu,vec] = powermethod(A,x,tol,N) % power vec = powermethod(A,x,tol,N) x=x./max(x) k=1 error=2*tol while k<=N & error>tol, y=A*x mu=max(y) y=y./mu error=max(abs(x-y)) x=y end vec=x
function [video_mat] = traces_to_mat(traces, szv, keep_ind) %[I J] = ind2sub([szv(1,1) szv(1,2)], keep_ind); %set_to_zero = setdiff(all_ind, keep_ind); % return values in all-ind that are not in to_keep % setting all pixels not in traces to zero video_mat = zeros(szv); frame = zeros(szv(1,1), szv(1,2)); for i...
s0 = [v0; r0]; % Part (a1) alpha = 0.1; [~, s1] = ode45(@(t,s) particleDeriv(s, alpha), [0 1000], s0); r1 = s1(size(s1, 1), 4:6); % Part (a2) alpha = 0.2; [~, s2] = ode45(@(t,s) particleDeriv(s, alpha), [0 1000], s0); r2 = s2(size(s2, 1), 4:6); % Part (a3) alpha = 0.3; [~, s3] = ode45(@(t,s) particleDeriv(s, alpha),...
function T0_n=mat_hom(theta,alpha,r,d,k) %matrice homogène n=length(theta); T0_n=eye(4);%= future matrice homogène for i=1:k T=[cos(theta(i)) , -sin(theta(i)) ,0 ,d(i); cos(alpha(i))*sin(theta(i)), cos(alpha(i))*cos(theta(i)), -sin(alpha(i)), -r(i)*sin(...
function [ y,f ] = fftAnalysis(y,fs) n = length(y); y = fft(y,n,2); y = abs(y/n); f = (0:n-1)*(fs/n); end
%apply the formula proven by thr previous subquestion %(b) clear all; L=2*10^-3; R=8; C=5*10^-6; I(1)=0; DI(1)=0; dt=0.00001; Vs(1)=0; for t=1:1:1000 Vs1(t)=(cos(6000.*(t.*dt+dt))-cos(6000.*t.*dt))./dt; DI(t+1)=DI(t)+((Vs1(t)-R.*DI(t)-I(t)./C)./L).*dt; I(t+1)=I(t)+DI(t+1)*dt; ...
%takes an array, indicesStart, and a traceLength, and returns a matrix %containing the elements of indicesStart through indicesStart+traceLength. %For Example a = [3 17 42], traceLength = 2 will return % windows = [3, 4, 17, 18, 42, 43] function windows = getWindows(indicesStart, traceLength) tempOnes = ones(length...
%% PLANT DISCRETIZATION AND AUGMENTATION for i = 1:length(S) hs = S(i); delay = delays(i); sysd = c2d(sysc, hs); Ad{i} = sysd.a; Bd{i} = sysd.b; Cd{i} = sysd.c; sysd_b0 = c2d(sysc, hs-delay); sysd_b1 = c2d(sysc, hs); B_0{i} = sysd_b0.b; B_temp = sysd...
function [] = plotAccuracyVsC(Cs, trainX, train_y, testX, test_y, alg, maxIter) tr_accuracies = zeros(length(Cs), 1); ts_accuracies = zeros(length(Cs), 1); for i=1:length(Cs) c = Cs(i); [w, b, SupVec] = trainSVM_QP(trainX, train_y, c, alg, maxIter); [e1_train_svm, e1_test_svm, e2_train_svm, ... e2_test_svm...
function y = decoder_constellation(x,con) x = conj(x); xr = zeros(size(x)); xi = zeros(size(x)); consts = [3; 1; -1; -3;]; difs = zeros(4,1); difsj = zeros(4,1); %decide which element of the constellation a received symbol is closest to for k=1:length(x) difs = real(x(k)) - consts; ...
%cd '/Volumes/LJBIGBOY/prospectus_analysis/dissertation/conrols_LOO'; cd '/Volumes/LJBIGBOY/prospectus_analysis/dissertation/aim_2/originalsLOOZ'; warning ('off', 'MATLAB:unknownElementsNowStruc'); d = dir ('FINz*FIN.nii'); for i = 1:length (d) pname = d(i).name; hdr = spm_vol(pname); img = spm_read_...
data = load('ex1data1.txt' ); X = data(:, 1); y = data(:, 2); plot(X, y, 'rx', 'MarkerSize', 10); ylabel('Profit in $10000'); xlabel('Population of City in 10000s'); m = length(y); X = [ones(m, 1), X]; theta = zeros(2,1); alpha = 0.01; //theta = theta - alpha * (1 / m) * ((theta' * X - y) * X); J = computeCost(X, y, th...
function ret = visualize_featurecsv(inputfilename) % visualize csvfile of feature-temporal 2D % USAGE % vonormalize( filename.csv ) % OUTPUT % filename.png [pathstr,name,ext] = fileparts(inputfilename); A = load(inputfilename); img = image_rowsc(A'); caxis([0 1.0]); saveas(img, [pathstr, name, '.png']); waitfor(im...
clear all hold on % 1. Dla danych ze strony www narysuj wykres rozproszenia, traktujac % pierwsza kolumne jak zmienna objasniajaca, a druga jako zmienna % objasniana. Znajdz przyblizona zaleznosc funkcyjna pomiedzy danymi % wykorzystujac toolbox cftool. data_1 = load('dane_zad1.m'); x1 = data_1(:, 1); y1...
function h = imagescnan(varargin) % IMAGESC with NaNs transparent % % MvdM 2014 switch (nargin) case 1 hh = imagesc(varargin{1}); a = varargin{1}; case 3 hh = imagesc(varargin{:}); a = varargin{3}; end set(hh,'alphadata',~isnan(a)); if nargout > 0 h = hh; end
% Function to calculate the relative error function e = RelativeError(val1, val2, type) for i = 1:length(val1) e = max(max(abs(val1{i} - val2{i})./max(eps, abs(val1{i} + val2{i})))); disp(['Relative error grad_' type num2str(i) ': ' num2str(e)]); end end
function baseRepresentation = ind2base(d, b, n) %IND2BASE Convert decimal integer to base-B representation. % IND2BASE(D,B) returns the representation % of a non-negative integer D as a integer in base B. IND2BASE(D,B,N) % produces a representation with at least N digits. If D is an array, % IND2BASE return...
clear; clear figs; %monkey = 'Pepe'; monkey = 'Satchel'; load(sprintf('%s/bcidistance.mat',monkey)); load(sprintf('%s/bciacqtime.mat',monkey)); load(sprintf('%s/blockshamacqtime.mat',monkey)); load(sprintf('%s/blockshamdistance.mat',monkey)); load(sprintf('%s/sessindindex.mat',monkey)); unique_sessidx = unique(sess...
% Returns the covariance matrix of the Distance Sensor % INPUT: % Sensor Error Constants (S=[sigma_rho sigma_phi]) % sigma_rho~Distance error % sigma_phi~Angle error % % OUTPUT: % Qt function [ Qt ] = getSensorCovariance(S) sigma_rho=S(1); sigma_phi=S(2); Qt=[(sigma_rho)^2 0;...
% INTRODUCTION % Script to process image data of Atlantis phantom. function [] = Proton(VarFile) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % PREPARATION % Prepare workspace: clearvars -except...
function [lambda, V, iter] = power(A,X,epsilon,maxI) %Input - A is an N x N matrix % - X is and N x 1 matrix: the initial guess % - epsilon is the tolerance % - maxI is the maximum number of iterations %Output- lambda is the dominant eigenvalue % - V is the dominant eigenvector % - iter is the...
% Author: Aditya Prawira %% STALKER ROBOT SIMULATIONS clear clc set(0,'DefaultFigureWindowStyle','docked') % Docked simulation. %% KEY BINDING ASCII CODE CONSTANTS FORWARD = 82; BACKWARD = 81; LEFT = 80; RIGHT = 79; ESC = 41; ENTER = 13; KEY_D = 7; % d key KEY_A = 4; % a key %% SIMULATION ENVIRONMENT SETUP INTERFAC...
function [ output_args ] = printMV(label, f, motion_vectors ) %PRINTMV Summary of this function goes here % Detailed explanation goes here x=[1 17 33 49 65 81 97 113 129 145 161]; x_axis=[x x x x x x x x x]; y=[1 17 33 49 65 81 97 113 129]; y_axis=[...
function [ds_quant,p] = quantize_prob(ds,edges) %This functions gives the probability of each samples according to the %quantization dictated by the bins described in the edges %inputs % ds: n*p matrix representing the n samples of p parameters % edges: cell of p matrix containing the sequence of bi...
%% Position et Vitesse depuis Gauss function xC = Gauss2Cart(mu0,x) P = x(1); ex = x(2); ey = x(3); hx = x(4); hy = x(5); L = x(6); co = cos(L); si = sin(L); W = 1 + ex*co + ey*si; Z = hx*si - hy*co; C = 1 + hx^2 + hy^2; r = P/(C*W)*[(1+hx^2-hy^2)*co + 2*hx*hy*si;... (1-hx^2+hy^2)*si + 2*hx*hy*co;... 2*Z]; v = s...
%% Matlab Colony Analyzer Tutorial % Gordon Bean, June 2013 % gbean@ucsd.edu % % I suggest making a copy of this tutorial (or sections thereof) for % analyzing you own images. % % This toolkit depends on the MATLAB Image Processing Toolbox and the % Statistics Toolbox. % If you would like to use the toolkit and do not ...