text
stringlengths
8
6.12M
#!/usr/bin/octave %x=linspace(-2*pi,2*pi,100); [x,y]=meshgrid([-2*pi:2*pi:100],[-2*pi:2*pi:100]); z=x-x for i=[0:1000] z=sin(y)*sin(x) surf(x,y,z); axis([0 1 0 1 -4 4]); shading interp; plot(x,y,z); sleep(0.01); end
function [ output_args ] = plotbarra( P1,P2,P3,P4) %UNTITLED7 Summary of this function goes here % Detailed explanation goes here %dibujar barras plot([P1(1);P2(1)],[P1(2);P2(2)]) hold on; plot([P2(1);P3(1)],[P2(2);P3(2)]) plot([P3(1);P4(1)],[P3(2);P4(2)]) hold on %dibujar puntos plot(P1(1),P1(2),'o') plot(P2(...
clc; clear all; close all; run('init.m') load('scope_data_exp1_2'); figure subplot(1,3,1); plot(scope_data(1,:), scope_data(6, :), 'LineWidth', 2) title('Elevation') xlabel('Time [s]') ylabel('Angle [deg]') grid on subplot(1,3,2) plot(scope_data(1,:), scope_data(4, :), 'r', 'LineWidth', 2) title('Pitch') xlabel('Tim...
function [] = shift_axes(ax, dx, dy) %% function [] = shift_axes(ax , dx, dy) % this function shifts a given set of axes ax % by dx and dy for i = 1:prod(size(ax)) set(ax(i), 'Position', get(ax(i), 'Position') + [dx dy 0 0] ); end
global fonttype global fontsize load('rawMaterial\result_N400_OLin.mat') prm.model = '3dof'; prm.loiter = true; prm.correctChi = true; prm.p = 1; trajData = getTrajData(Z, N, prm); d = 3; finalFE = spectralMethodGen(trajData, @jac3DoF, d); prm.correctChi = false; trajData = getTrajData(Z, N, prm); N = linspace(40, ...
%% mainPassive % is a simple solver for the transport of a passive scalar (enthalpy, % mass-fraction, momentum component in third direction, ...) in 2D % (C) Andreas Kempf, 21.5.2013, code for "Numerics and Fluid Flow Simulation" % course at the University of Duisburg-Essen %% Preparation clc; clear; hold off; %%...
function [mean] = Average(DATA, t_begin, t_end) % This is perting C++ code of B and O (2010), FDR paper % Detailed explanation goes here mu=0; for t=t_begin:t_end mu=mu+DATA(t); mean=mu/(t_end-t_begin+1); end end
function [] = checkMultiModal3Cost() % Check the gradients for the stacked autoencoder % % In general, we recommend that the creation of such files for checking % gradients when you write new cost functions. % %% Setup random data / small model % inputSize = 4; % hiddenSize = 5; % lambda = 0.01; % data ...
function [result, features] = classify(im, models) global SUBIMAGE_SIZE global VERBOSE global THRESHOLD global FIG_SUBIMAGE global FIG_HIST features = [struct('min_diff', {}, 'matching_subimages', {}, 'sum_diff', {})]; for k = 1 : length(models) features(k).min_diff = -1; ...
function [bincenters,averages,errors]=bincumulative(x,y,min,max,oversamplingratio,nbins,varargin) binwidth=(max-min)/nbins; binedges=linspace(min,max,nbins+1); bincenters=min+binwidth/2:binwidth:max-binwidth/2; averages=NaN(1,nbins); errors=NaN(1,nbins); if nargin==6 for i=1:nbins averages(i)=nanmean(y(x>...
function [x, y]=Heun(func, y_init, x_init, x_end, nstep) % Written By Ali Al-Alawi August 2013 % Student ID: 23393262 % Matlab Function of the Heun Method % func: the ODE to be solved % y_init: Initial y value % x_init: Inital x value % x_end: Final x value % nstep: No. of steps to get from x_init to x_end % x: x va...
data = readTxt('updated_train.txt'); attributes = ['2','3','4','5','6','7','8']; attributesLive= [1,1,1,1,1,1]; [rows,cols] =size(data); node = id3(data,attributes,rows, attributesLive); errorsList = visitNode(node, data); disp('Q1-3. the rows of error prediction when the updated_train.txt as test data.'); disp(...
%% 5.1 b close all %plotting the first response amplitude = 1; frequency = 0.005; sim("ship_5_b.mdl") figure plot(simout,'LineWidth',1.5) hold on plot(simout.Time,ones(1,length(simout.time))*max(simout.data),'-.m','LineWidth',1.5) plot(simout.Time,ones(1,length(simout.time))*min(simout.data(3000:end)),'-.r'...
% expl. Euler mit Ein-/Ausstroemung % Geschw./Partikel % Wandgeschwindigkeit function [] = Num_1_Wirbelstroemung_GUI_05(t,video_jn,video_name) %% Hauptteil % Ein/Aus Geschw: Num_1_Wirbelstroemung_GUI_Geschw_EinAus(...) % u_EA_L = U_EA(1,1); % u_EA_R = U_EA(2,1); % u_EA_O = U_EA(3,1); % u_EA_U = U_EA(4,1); U_EA = [0;...
%===================================== % ECE 6104 Project 1 Validate PIC routines % Kevin Diomedi %===================================== %===================================== %Spectral solver validation %===================================== %addpath('../hw1'); %Q6 %===================================== %Electric ...
clear variables ; close all; clc; N = 5000; %Nb exp loi = 2 switch loi case 1 %Loi Uniforme n = 25; X = zeros(1,N); for k = 1:N; X(k) = LoiUniforme(n); end case 2 %Loi Bernoulli p = 0.5 n = 50 X = zeros(1,2) for k = 1:n if L...
function dydt = simp_pend_opt(t ,y , k_fb, k_ff, u_desired, t_desired, x_current, t_current) % K_int = interp1(t2,k_opt,t); % dydt = [y(2); ( -K_int*[y(1); y(2)] - y(2) - y(1) ) ]; % k_fb_int = interp1(t2, k_fb, t); % k_ff_int = interp1(t1, k_ff, t); % y(1) = wrapToPi(y(1)); k_fb_int(1,1) = interp1(t_current', k_f...
function configureLocalization %peg 10 IsLastRangingNode(1); %peg 10 IsLastRangingNode(1); %peg 10 IsLastRangingNode(1); %peg 10 IsLastRangingNode; %peg 10 IsLastRangingNode; %peg 10 IsLastRangingNode; peg all MaxAnchorRank(500) pause(0.25); peg all MaxAnchorRank(500) pause(0.25); peg all MaxAnchorRank(500) pause(0....
%% Name - Sheel Nidhan % Date - 11th September, 2019 % Plots for the eigenvalues results for prf_spod_re5e4_frinf paper clear; dirout = '/home/sheel/Dropbox/research/sheel_papers/prf_spod_re5e4_frinf/template/figures_2.0/'; %% Generating the figure object close all; x0=0; y0=0; width=15; height=15; set(gcf, 'units'...
%% Read the value of a TT from OPC (by simple name) % % level = ppGetLevel(pointTag) % % Returns: % level Value read from OPC as double % % Examples: % level = ppGetTemp("cstr1"); % function value = ppGetLevel(pointTag, recordCount) arguments pointTag string recordCount uint16 = 1...
function excitation = getForce(wave,time,elevation) % getForce.m E.Anderlini@ed.ac.uk 23/12/2016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This function is used to obtain the wave excitation force from the wave % elevation and the diffraction impulse response function. %...
function qqt = sq_exp(u1,v1,w,sigma) if (size(u1,1)<size(u1,2)) u1 = u1'; end if (size(v1,1)<size(v1,2)) v1 = v1'; end u = repmat(u1,1,length(v1)); v = repmat(v1',length(u1),1); qqt = sigma.*exp(-(u-v).^2./(2*w^2)); end
%% Initialization clear ; close all; clc addpath('./libsvm-3.22/matlab'); %% ==================== Part 1: linear SVM ==================== %% 加载数据 [train_y, train_x] = libsvmread('email_train-all.txt'); %% 获取大小 [m,n] = size(train_x); b = [train_x train_y]; csvwrite('train.csv',b); model = svmtrain(train_y, train_x, s...
function [looclass1,class2,Kopt,error_array]=multiclass_knn(input1,class1,input2,K) % % Use simple squared dist to compute the nearest % neighbor classes by voting in K neighbors. % % INPUT: % % input1, input2: input vectors for training and test set (D x N) % class1: vector ( N X 1) with the class labels range 1:C ...
%M300x.m %help file for M300x.dll % % returns -1 on error % Three main commands % (defined in globals_mii.m as strutures C_ and M_) % % C_.INIT % % C_.MODE % source for left (M_.SOURCE1 or M_.SOURCE2) % source for right (M_.SOURCE1 or M_.SOURCE2) % % C_.DATA % S1atten followed by S2atten %
%% % Solves a linear system where the user manages the mesh--solver interactions % % Set the Matlab path and initialize PETSc path(path,'../../') PetscInitialize({'-ts_monitor','-snes_monitor','-ksp_monitor','-ts_theta_theta','1'}); %% % Open a viewer to display PETSc objects viewer = PetscViewer(); viewer.SetType(...
function [a] = teststats() %TESTSTATS Look at all the functions in 'mfiles' and then calculate the %usage by scanning the 'tests' folders. % % Returns an array of structs (a.name a.count) % % Also writes to a comma separated file, 'teststats.csv' % % Example: [a] = teststats(); % % Find the ones that are not getting...
clear; clc; close all; data = readtable('iris.txt'); data.Properties.VariableNames{1} = 'sepal_length'; data.Properties.VariableNames{2} = 'sepal_width'; data.Properties.VariableNames{3} = 'petal_length'; data.Properties.VariableNames{4} = 'petal_width'; data.Properties.VariableNames{5} = 'species'; x1 = t...
function [x, flag, iter, xs] = Secant(fun, x0, x1, tol, maxIter) % Secant Find zero of single-variable function using secant method. % X = Secant(FUN, X0, X1) returns a zero of FUN within X0, X1 as the % first two points using Secant method. FUN should be a function handle % taking a scalar as input and X0, X1...
function obj = setReference(obj, ref) % set the reference frame % % Parameters: % ref: the reference frame object @type CoordinateFrame assert(isa(ref,'CoordinateFrame'),... 'The reference frame must be a CoordinateFrame object.'); obj.Reference = ref; % update the homogene...
%% ID: 182482526 %% Name: Hasibul Islam Nirob func=@(x) x.^3-21*x+3500; derivFunc=@(x) 3*x.^2-21; x=-15; h = func(x) / derivFunc(x); while abs(h)>=0.001 h = func(x)/derivFunc(x); x = x - h; endwhile fprintf('The root is : %f',x);
% Demonstration of the View-morphing method % addpath('C:\opencv\mexopencv') % addpath(genpath('C:\Users\VitoS\Documents\Administracija\Consulting\Jobs\EngineUpgrade_20141119\working_copy_code\opencv')) % cdir = fileparts(mfilename('fullpath')); % addpath([cdir,'\face_and_landmark_detector']) addpath('face_and_landmar...
% sistem b = 5; t = 4; L = -5; U = 5; % b = baza , t= dolzina mantise, L,U=meje eksponenta %kodo rabim povecat za for zanko ce imam vecji t oz zmanjsati %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % mantise c = 0:b -1; M = zeros ( b ^t ,1) ; i = 1; for c1 = c fo...
% This code is used to fit a DDM for the computational modeling workshop challenge % Research questions: % 1. Does the drift rate change with respect to the 'closeness' of a picture to the decision boundary? % The hypothesis is that as the strength of evidence for a certain option decreases (e.g., get closer % to the m...
function [spikesValue, spikesTime]= SpkDet_PTSD_SA(data, thresh, plp, rp, npa); %================================================================= % % SpikeDetection_PTSD % % The calling syntax is: % % [spkValues, spkTimeStamps] = SpkDet_PTSD_SA(data, thresh, plp, rp, npa) % % data -> signal raw dat...
function qualityMatrix = qualityMatrixFinal( Actions ) %QUALITYMATRIXFINAL this function extacts the information about the quality %from the complex Actions structure % USAGE : qualityMatrix = qualityMatrixFinal( Actions ) % INPUT: % Actions - a complex structure containing information about the impact % and the q...
% x为插值点 % xi为待计算点 function Test3(x, xi) y = sqrt(x); yi = Lagrange(x, y, xi); yFact = sqrt(xi); err = yFact - yi; fprintf('计算插值点xi:\n'); disp(xi); fprintf('计算得插值yi:\n'); disp(yi); fprintf('插值点处函数值yFact:\n'); disp(yFact); fprintf('计算误差err:\n'); disp(err); plot(x, y, '-b', xi, yi, '-r', xi, yi, 'og');
function varargout = dddtreecfs(option,dt,varargin) %DDDTREECFS Extract or reconstruct dual-tree coefficients. % OUT = DDDTREECFS(OPTION,DT,PARNAM,PARVAL, ...) reconstructs % or extracts coefficients from the tree DT, OUT depends % on PARNAM and PARVAL. % If OPTION equal to 'r' reconstructions are done else, %...
%User Kill Script %this script, when saved in the current protocol folder, will be executed %at Bpod termination. %Serves for custom and protocol specific action at session end. %% PUT USER-SPECIFIC STUTT HERE%% % For example, save behahior figures, do additional analyses and send % results by e-mail. For example scri...
function [dioValue, counterOut, exitFlag] = waitForCounterChange(dio, WHICHRIG, timeOut) %WAITFORCOUNTERCHANGE Samples the digital and returns only when counter %updates, indicated new data on DIO lines % Eric Trautmann - etrautmann@gmail.com % 2/7/12 exitFlag = 'success'; if nargin < 3 ti...
function prompt(varargin) % NAME % prompt % % SYNOPSIS % % prompt(varargin) % % ARGS % INPUTS % varargin in if any variable is passed, % the 'prompt' will pause % before evaluating the % input() function call. This % helps to prevent MatLAB % ...
function SimScore = PDBID_StructureSimilarity(s1, s2) %% if s1 == s2 % SimScore = 1 %first, split the s1 and s2 into pdb ids slist1 = buildkeyset(cellstr(s1)) slist2 = buildkeyset(cellstr(s2)) %function [ keywords ] = buildkeyset( colcell ) % build a keywords set from the column value of uniprot l1 = length(slist...
%RTBDEMO Robot toolbox demonstrations % % Displays popup menu of toolbox demonstration scripts that illustrate: % - homogeneous transformations % - trajectories % - forward kinematics % - inverse kinematics % - robot animation % - inverse dynamics % - forward dynamics % % Notes:: % - The scri...
function varargout=test_fpb_corr(varargin) if nargout>0 [varargout{1:nargout}]=feval(varargin{:}); else feval(varargin{:}); end %------------------------------------------------------ function [D3u, R, HW]=make_test_data % run a tx-pulse-shape correction simulation for a range of surface roughnesses (R). % ...
%============================================================== % FileName: elem_nbenergy.m % Description: Get non-bonded energy in a element % Author: Changhao Li % Date created: 20 Jul 2017 % Version: 1.00 % Date last revised: 20 Jul 2017 % Revised by: Changhao Li %============================================...
function a=read_array_2d(filename) % a=rad_arrray_2d(filename) % read 2d matrix written by write_array_2d d=load(filename); m=d(1); n=d(2); if length(d)~=m*n+2, error('wrong number of terms in the file') end a=reshape(d(3:end),n,m)'; end
for ii = 1:3 a1 = allFates_small{ii}; a1(a1 == 0) = 0; % media a1(a1 == 300) = 8; % sox2 a1(a1 == 200) = 30; % T a1(a1 == 100) = 15; % cdx2 figure; imagesc(a1); colormap(jet); axis off; end %%
function strOut = pickle( A , precision ) if isa( A , 'char' ) classTag = class(A); sizeTag = num2str(size(A)); serialData = A(:)'; strOut = [ classTag ':' sizeTag ':' serialData ]; else classTag = class(A); sizeTag = num2str(size(A)); serialData = num2str( A(:)' , precision ); strOut =...
% Reads LiDAR distances until an obstacle is detected in front of the user % expected format: measured dist,ground dist % - SerialPort: serialport object corresponding to SCI1 function readLidar(SerialPort) % flags to synchronise with C program send_lidar = sprintf("2\n"); stop_lidar = sprintf("0\n"); ...
function [varargout] = InitializeInstr(obj) % Initialize instrument % adcmt 6166: 6161-compatible mode must be set to ON (set by using the instrument front panel) % Copyright 2015 Yulin Wu, Institute of Physics, Chinese Academy of Sciences % mail4ywu@gmail.com/mail4ywu@icloud.com ErrMsg = ''; TYP = l...
function [DepNO2,DepH2O2,DepO3,DepHCHO,DepHNO3,DepNO,Gst] = deposition(gst,t,hour,T,lw,z,RH,PAR,f_light,LAIcum,Rsoil, Vcut, Vst,H,u_os,g_min,VPD_min, VPD_max,SWP_min, SWP_max, SWP,SGS ,EGS, gpot_a , gpot_b, gpot_c,hhti,hlti,vegtype,depscheme, Ptorr,Rm) %depositions in units of s^-1 %parameterization of leaf boundary re...
function [Z p]=PG_GOOPSI(P,X,t,N) %Grid function rho(X,t,N) [for GOOPSI:Vogelstein-Paninski setup] %Z=PG(P,[],t,N) returns a sample of N X's from rho(X,t). %Z=PG(p,X,t) computes rho(X,t). If X is a NxM matrix of N M-dimensional %states, Z is Nx1 vector of such probabilities P_i=rho(X_i,t). %[Z,P]=PG(p,[],t,N) retu...
%% Create a mmodel for attribution analysis using the 3-factor Brinson model. % That ideally calls on our daily Citi feeds from Citi. function [ansa] = attribution(ft0, ft1, bt0, bt1, fccy, bccy, sdate, edate) ansa = ft1./ft0; end
function [x, y, z, f] = field(g, lmax, p, dp, b, theta, phi, comp) % Subroutine to calculate x, y, z and total field at given coordinates % from a set of schmidt quasi normalised spherical harmonic % coefficients. includes downward continuation. Assumes an % internal source. ...
%Volume based Metrics % function [rmse, mad, ave] = Volume_Metrics(vol_GT, vol_Alg) function [rmse, mad, ave] = Volume_Metrics(vol_GT, vol_CMF, vol_FWHM, vol_STRM, endloop) rmse = ....rmse_CMF, rmse_FWHM, rmse_STRM [sqrt(mean( (vol_GT(:) - vol_CMF(:)).^2 )),.... sqrt(mean( (vol_GT(:) - vol_FWHM(:...
% Load model parameters quanser_aero_parameters; % %% Control Specifications % Peak time and overshoot specifications PO = 7.5; tp = 1.75; % Damping ratio from overshoot specification. zeta = -log(PO/100) * sqrt( 1 / ( ( log(PO/100) )^2 + pi^2 ) ); % Natural frequency from specifications (rad/s) wn = pi / ( ...
%% This is for playing with data coming from Google Takeout % filtered with parse_location.js disp('reading data...') % Modify this with your own data % Filter it with parse_location.js first data = dlmread('samples/locations.tsv', '\t'); % Heavy down-sampling to speed up later integration d.x = data(1:1000:end, 2:3...
%set up a function to incorporate the entire equation function pupilDiameterMm = getPupilSize(ageYrs, luminanceCdM2, fieldDiameterDeg, eyeNumber, whichModel) %% W&Y's (2012) unified formula fieldSizeDeg = ((fieldDiameterDeg/2)^2)*pi; % switch will allow to chose which model we want to look at switch whichModel case...
function [XX_k1k1, z_pred, IEKFitcount] = IEKF(U_k, Z_k, dt, stdv, stdw) % IEKF Function for running Iterated Extended Kalman Filter. % % Inputs: % - U_k: input vector % - Z_k: measurement vector % - dt: timestep % - stdv: sensor noise statistics % - stdw: process noise statistics % % Output: % - XX_k1k1: one-s...
% $Header: svn://.../trunk/AMIGO2R2016/Kernel/IVP_solvers/sens_analysis_1.1/AMIGO_loop_senssys.m 1803 2014-07-14 14:28:02Z attila $ options = odeset('RelTol',inputs.ivpsol.rtol,'AbsTol',inputs.ivpsol.atol,'BDF','on'); y_0=privstruct.y_0{iexp}; sens_y0=inputs.PEsol.sens0; if privstruct.t_int{iexp}(1)==inputs.exps.t_...
function[interval, start]=getSampleInterval_smr(fID,chan) % getSampleInterval_smr returns the sampling interval in seconds % on a waveform data channel in a file, i.e. the reciprocal of the % sampling rate for the channel, together with the time of the first sample % % [INTERVAL{, START}]=getSampleInterval_smr(FID, CH...
%% some numbers. % all times are in [ms] dt = 2; tmax = 1000; tmin = -200; fs = 1/dt; len_sample = floor((tmax-tmin)*fs); t = linspace(tmin, tmax, len_sample); N2_widths = 50:50:401; ratio_jitters = [0 0.05 0.3 0.55 0.8 1.05 1.3]; num_trails = 100; freqs = logspace(log10(2), log10(60), 30); tot_erp = zeros(length(N2_...
%%% % Creates Figures on cell bias towards aggreagtes %%% addpath('Libraries/Utils') addpath('Libraries/TrajectoryAnalysis/') PROJECT_BASENAME = ['/Volumes/Scratch/Chris/Paper2_Rippling/Paper2/']; run('ENVS.m') load([PROJECT_BASENAME, '/data/processed/Development/AllData.mat']); %AllData cell indicies for each movie ...
function varargout = gui_workspace(varargin) % GUI_3DVIWER MATLAB code for gui_3dviwer.fig % GUI_3DVIWER, by itself, creates a new GUI_3DVIWER or raises the existing % singleton*. % % H = GUI_3DVIWER returns the handle to a new GUI_3DVIWER or the handle to % the existing singleton*. % % GUI_3DV...
function drawResult( obj, field ) isFigureEmpty = isempty( obj.drawHandle ); if isFigureEmpty drawNewFigure( obj, field ); return; end if isvalid( obj.drawHandle ) updateFigure( obj, field ); else drawNewFigure( obj, field ); end end function updateFigure( ...
function b = colormap_scaledata(map,a) b = nan(size(a)); if sum(sum(~isnan(a))) >1 % if more than one data point in a n = size(map,1); m = min(min(a)); mx = max(max(a)); scale = m:(mx-m)/(n-1):mx; for si = 1:numel(scale)-1 b(a>=scale(si) & a<=scale(si+1)) = si; end b(a==scale(en...
load pred1.dat load resp1.dat X = pred1(1:500,50); % Predictors Y = resp1(1:500); % Responses yMean = mean(Y); xMean = mean(X); n = numel(X); w1numer = sum((X-xMean).*(Y-yMean)); w1denom = sum((X-xMean).^2); W1 = w1numer / w1denom; % m slope W0 = yMean - (W1*xMean); % b intercept % y = m*x + b //minimizes error....
clc s = load('dbworld_bodies'); mat = cellstr(s.dictionary); % reading words in to matrix mat= mat'; word_mat = struct([]); % char word_mat = zeros([1 4702]); % for comparing words with inputs % % email_mat = struct([]); % for individual emails filePh = fopen('msg1.txt','w'); %This loop is written for...
function [W, E, Epos,Epos2,Epos3,Epos4, H, r, lam,I,LT, testf, testf2, Elamt] = plotenergy(Sol , pos, alpha, FvsZp) R0=4; k0 = 320; %k2 = -0.53*k0; k2=0; mesh = (0:1/2000:1).^2; t = alpha*mesh; H(:,:) = [Sol(4,:,:) Sol(10,:,:)]/R0; r(:,:) = [Sol(1,:,:) Sol(7,:,:)]*R0; y(:,:) = [Sol(2,:,:) Sol(8,:,:)]*R0; lam(:,:) = [...
function [listeX, listeY, listeT] = extractTraj(id, X, Y, T) listeX = {}; listeY = {}; listeT = {}; [lenT, j] = size(id); i = 1; while i < lenT j = id(i); k = i + j - 1; listeX{end + 1} = X(i:k); listeY{end + 1} = Y(i:k); listeT{end + 1} = T(i:k...
fprintf('Welcome to Week #13 of ECS1200 for Bioengineering\n'); % determine the Arduino comport serialInfo = instrhwinfo('serial'); for k = 1:length(serialInfo.SerialPorts), comports(k) = str2num(serialInfo.SerialPorts{k}(4:end)); end h = find(comports>=3); if isempty(h) fprintf('No Arduino COM port found.\n...
%Copyright 2017, Jinyan Zhang, All rights reserved. %Jinyan Zhang, Student ID# 2447878 %Course AE413, Homework 1, Question 1. function ATMOS = atmos(h) %Input: height in feet. ATMOS = struct('H', {}, 'T', {}, 'P', {}, 'Rho', {}, 'a', {}); g=9.80665; h0=0; h1=11000; h2=20000; T0=288....
%% %(1) clc REPS=1000; for N=[2,4, 8] tic; for i=1:REPS dftmtx(N); end toc for i=1:REPS DFTmatrixA(N); end toc end %hacer tabla con valores %% %(2) close all for N=[4,32,256] A=DFTmatrixA(N); figure clear A_aux; A_aux(:,:,1)=real(A); A_aux(...
fprintf("1") t = [pi/2 -pi/2 pi/2 pi/3 pi/2]; dt = [0.1 0.3 0.2 -0.1 0.6]; [linear_V, angular_V] = speed(t, dt) fprintf("2") %t0 = [0 0 0 0 0 0]; t1 = [pi/2 -pi/2 pi/4 -pi/6 pi/8 -pi/3]; dt1 = [0.1 -0.2 0.3 0.1 0.4 -0.6]; %H = puma_FK(t0) [linear_V, angular_V] = puma_speed(t1, dt1)
function zfft1(in_path,out_path,points,fft_max) % zfft1 do a fft on the third of three dimensions % data was saved as interleaved complex using this code in rad_mat. ~line 2175 % A=data_buffer.data; % A=[imag(A(:)');real(A(:)')]; % A=A(:); % % ...
clc close all clear %% load data load('ECGdata.mat') %% setup GAN training data maxLabel = max(TrainingLabels); numSamplesPerClass = zeros(1,maxLabel); for i = 1:maxLabel numSamplesPerClass(i) = sum(TrainingLabels == i); end maxSample = max(numSamplesPerClass); numGanTrainingPerClass = zeros(1,maxLabel); for i = 1:...
clear;clc;clf %海平面4個時間的風速與風向 t=[1 2 3 4]; %時間 y=zeros(1,4) %把4個y固定在0 speed=[5 6 3 7] %風速 theta=[0 90 180 270] %風向 %向右是0度(東邊) %向上是90度(北邊) u=speed.*cosd(theta) v=speed.*sind(theta) quiver(t,y,u,v) %在座標軸為t和y的點上繪出一個箭頭 %箭頭的大小方向由矩陣u和矩陣v來決定
function [n] = Plot_Matrix(Status,Fig) [m,n] = size(Status); row = m; column = n; a=-column/2-0.5; b=row/2+0.5; c=0; figure(Fig) for i=1:1:row b=b-1; for j=1:1:column a=a+1; if a>column/2 a=-column/2+0.5; end c=c+1; if Status(i,j) == 1 ...
function test_sqrt % Test code for the quaternion sqrt function. % Copyright © 2006 Stephen J. Sangwine and Nicolas Le Bihan. % See the file : Copyright.m for further details. disp('Testing square root function ...') T = 1e-12; % Test 1. Real quaternion data. q = randq(100); compare(q, sqrt(q) .^2, T, 'quaternion...
function [ srgb, trgb, outImg] = stpReinhard(spath, tpath) %% 把spath中的图片颜色迁移到tpath中的图片上 %% 读取并转换颜色空间 srgb = imread(spath); trgb = imread(tpath); slab = stpRgb2Lab(srgb); tlab = stpRgb2Lab(trgb); %% 计算方差和标准差 msl = mean2( slab(:, :, 1) ); msa = mean2( slab(:, :, 2) ); msb = mean...
good = load('lab_bioimaging/imT1.mat'); seg = load('t1.mat'); seg = double(seg.scirunnrrd.data(:,:,1)); x1 = good.imT1(:,:,1).*seg; x2 = good.imT1(:,:,2).*seg; x3 = good.imT1(:,:,3).*seg; x4 = good.imT1(:,:,4).*seg; x5 = good.imT1(:,:,5).*seg; x6 = good.imT1(:,:,6).*seg; x7 = good.imT1(:,:,7).*seg; x8 = good.imT1(:,:...
function precisions = precision_plot(result,groundtruth) figure(33); % hold off; max_threshold = 50; precisions = zeros(max_threshold,1); dd = (result(:,1) - groundtruth(:,1)).^2 + (result(:,2) - groundtruth(:,2)).^2; distances = sqrt(dd); for i = 1:max_threshold index = find(distances <= i); count = length(ind...
function [cons] = cca_consistency(X,xpred) %----------------------------------------------------------------------- % FUNCTION: cca_consistency.m % PURPOSE: check what portion of the correlation structure in data is % accounted for by an MVAR model, based on Ding et al 2000 % % INPUTS: X nvar...
function S = reconstruct_nuclear_norm(W, K) F = size(W, 1); P = size(W, 2); % [F, P, 2] -> [2, F, P] -> [2F, P] W = permute(W, [3, 1, 2]); W = reshape(W, [2 * F, P]); % Subtract centroid per frame. mu = mean(W, 2); W = W - mu * ones(1, P); % Compute SVD of W. [U, D, V] = svd(W, 'econ'); U = U(:...
function [ output ] = get_layer_output(data,trained_pars) %GET_POOLING_OUTPUT Summary of this function goes here % Detailed explanation goes here [h_states,~] = get_inference(data,trained_pars); output = cell(length(data),1); for i = 1:length(output) output{i} = polling(h_states{i},trained_pars.par...
function [y,fny] = Adams(trajectory,fn,h) %computing Adams %first step [P] = firstStep(trajectory,fn,h); %second step E(1) = v1(P(1), P(2)); E(2) = v2(P(1), P(2)); %third step [y] = thirdStep(trajectory,fn,E,h); %4th step fny(1) = v1(y(1), y(2)); fny(2) = v2(y(1),y(2)); end function [y] = firstStep(trajectory, fn, h...
function OutData = subfnAddConditionalEffectsToOutPut(OutData,AnalysisParameters) index = length(OutData) + 1; ModelNum = AnalysisParameters.ModelNum; Nmed = AnalysisParameters.Nmed; Nthr = length(AnalysisParameters.Thresholds); Thresholds = AnalysisParameters.Thresholds; Nvoxels = AnalysisParameters.Nvoxels; switch Mo...
function [U] = euler(L,Ncells,Nsteps) % This function solves 1D Euler equation using the Local Lax-Friedrich % scheme, where the source term is -\rho x. % Input arguments % L The length of interest % Ncells Number of cells % Nsteps Number of time steps % % Output arguments % U ...
[xs,fs,k] = grad_desc('f_h','Rosen',[2; -3],1e-6); [xs,fs,k] = grad_desc('f_h','Rosen',[-3; -3],1e-6); newton('f_h','Rosen','h_h',[2;3],0.1,1e-6); newton('f_h','Rosen','h_h',[-3;3],0.1,1e-6); newton('f_h','Rosen','h_h',[2;-3],0.1,1e-6); newton('f_h','Rosen','h_h',[-3;-3],0.1,1e-6);
function [media, des] = fun02(x) n = length(x); suma = 0; for k=1:n suma = suma + x(k); end; media = suma/n; suma = 0; for k=1:n suma = (x(k) - media)^2; end; des = sqrt(suma/n );
% Base class for CDPR observers % % Author : Chen SONG % Created : 2017 % Description : % The observer will estimate the system state (q, q_dot) and disturbance % (in forms of q_ddot and wrench). Depending on the specific observer, % some of the output may be not empty (not available from the obs...
% Copyright 2014 % % Licensed under the Apache License, Version 2.0 (the "License"); % you may not use this file except in compliance with the License. % You may obtain a copy of the License at % % http://www.apache.org/licenses/LICENSE-2.0 % % Unless required by applicable law or agreed to in writin...
hs = ones(numel(costs),2); ps = ones(numel(costs),2); num_costs = numel(costs); num_costs = 9; rep_sim = size(results.samples(c,2,:),3); all_bo = zeros(num_costs*rep_sim,1); all_mg = zeros(num_costs*rep_sim,1); for c=1:num_costs %Compare BSARSA and BO bs = squeeze(results.samples(c,2,:)); bo = squeeze(...
% Multi-Dim Rosenbrock % Credit to -> http://www.gatsby.ucl.ac.uk/~edward/code/minimize/rosenbrock.m function val = func(x) D = length(x); val = sum(100*(x(2:D)-x(1:D-1).^2).^2 + (1-x(1:D-1)).^2); sum(100*(x(2:D)-x(1:D-1).^2).^2 + (1-x(1:D-1)).^2) %val = sum(x.^2); end
% cd E:\GitHub\paper\lbfgs\lbfgs\lbfgs\minFunc_comprehension % addpath(genpath(pwd)) % mexAll grabcode('http://web.stanford.edu/~boyd/papers/admm/total_variation/total_variation.html')
function decWriteLEDs(LEDs,targetPWM,serialObject) targetPWM=ones(size(LEDs,1),1)*targetPWM; targetPWM(~LEDs)=0; targetPWM=repmat(targetPWM,1,12); % Convert 12 bit PWM value to binary for i=2:size(targetPWM,2) targetPWM(:,i)=floor(targetPWM(:,i-1)./2); end binaryConv=fliplr(mod(targetPWM,2)); % Split binary valu...
function [acf, pacf, qs] = uidents(y,lag,tit,s,graphics) % UIDENTS - Computes the autocorrelation and partial autocorrelation functions % for a set of series. % [acf, pacf, qs] = uidents(y, lag, tit, s,graphics) % y > (nxm) m series of n observations each. % lag > maximum lag for the ACF and PACF (default: ...
function [] = plot_dF(dF) nCells = size(dF,3); figure() for cellID = 1:nCells subplot (3,4,cellID) %plot([-1*pre:post],(dF(:,:,cellID)')) plot([-1*pre:post], mean((dF(:,:,cellID)'),2) - mean(mean(dF(:,1:900,cellID)))) title(['Cell', num2str(cellID)]) ylim([-0.05, 0.1]) xlim([-1000, 3000]) end end
function [eltime] = GVL_1_1_6(m, n, r) A = round(100*rand(m,r)); B = round(100*rand(r,n)); C = round(100*rand(m,n)); % [m, r] = size(A); % [~, n] = size(C); tic for i = 1:m for j = 1:n C(i,j) = C(i,j) + A(i,:)*B(:,j); end end eltime = toc; end
classdef RandomForestModelTest < ModelTest properties (TestParameter) % functional parameters fNum = {2}; % {1, 2, 6, 8, 13, 14, 15, 17, 20, 21}; dim = {2}; % {2, 5, 10, 20, 40}; m = {5}; % old model parameters % modelSpec = {'linear', 'quadratic'}; % minLeafSize = {10}; ...