text stringlengths 8 6.12M |
|---|
%--------------------------------------------------------------------------
% x2 신호들에 대해, x1신호 DTW 거리가 작은 N_s 개의 신호를 뽑은 후 변환하는 코드
%
% [xt] = dtw_search_n_transf(ref_singal, signals to transfrom,
% number of singals to extract)
%--------------------------------------------------------------------------
% by Ho-Seung Cha... |
%% define cloud
moments=[10 1^2; 20 1^2; 30 1^2];
object=SMASH.MonteCarlo.Cloud(moments);
view(object,'density','ellipse');
%% configure cloud
matrix=eye(3)/2;
matrix(2,3)=0.5;
matrix=(matrix+transpose(matrix));
object=configure(object,'Correlations',matrix,...
'VariableName',{'X' 'Y' 'Z'});
view(object,'density... |
%本程序验证报童模型运筹学解的优良性--收益大于遍历解
clc
clear
close all
%% 参数设置
sj=10; %产生随机数的次数
n=1000; %观测多少天
rate=1; %运价
fare=0.6; %仓容单位价格
D1=0.2E4; %试验仓容的最低值
D2=10.2E4; %试验仓容的最高值,D1和D2的取值是根据到货的分布
Gap=1000; %仓容每次的添加值
cs=(D2-D1)/Gap; %试验的次数cs
c=D1+Gap:Gap:D2; %试验的仓容序列,与试验的次数对应
m=10;v=0.5; %每天到来货物... |
function paint_enr(~,~,hfig)
HotBirdProp=get(hfig,'userdata');
cn=HotBirdProp.cn;
axes(HotBirdProp.handles.enrlegend);
reset(gca);
cmax = HotBirdProp.cs.s(cn).nr_fue;
cmin = min(min(HotBirdProp.cs.s(cn).lfu));
ncol = HotBirdProp.cs.s(cn).nr_fue;
fue=nan(HotBirdProp.cs.s(cn).nr_fue,1);
for i=1:HotBirdProp.cs.s(cn).nr_... |
%% Header
% Project Name: Domaci 1.
%
% File Name: main.c
%
% Author: Nemanja Jankovic, 2015/3303
%
% Date: 21/8/2016
clear all; close all; clc;
%% DEFINES
N = 100;
%% Function #1
Xmin = -4;
Xmax = 4;
Ymin = -4;
Ymax = 4;
[X, Y] = EquidistantPoints(Xmin, Xmax, Ymin, Ymax, N);
F ... |
% version 1: [ data, filename] = get_data( data_type, separator , msg, file_type)
% version 2: [ data, filepath] = get_data( data_type, separator , msg, file_type)
% Filepath is used instead of filename
function [ data, filepath] = get_data( data_type, separator , msg, file_type, givenFileName, givenFilePath)
% Retr... |
function [f] = read(path)
%returns the first line in the text file given in path
fid = fopen(path,'r');
f = fgetl(fid);
fclose(fid);
end |
%
% Inverse point kinetics example
%
% Read in pairings for (time,flux) and solve for period and reactivity
% as a function of time.
%
function [tstar,rho,conc,omega]=inv_kinetics(time,nd,beta,lam)
if nargin==0,
incdata = importdata('incore.dat');
time = incdata(:,1);
nd = incdata(:,2);
end
if nargin<3,
... |
function info = setParams
%%% data information
info.ncls = 20;
info.nsbj = 10;
info.nemp = 3;
info.vidpath = 'MSRAction3D';
info.imagespath = 'ColorImage';
end |
% Gibbs sampling.
%
% Arguments:
% y_init: The initial y value to use.
% weights: The weights of each feature function.
% ffValues: A cell matrix where the rows and columns correspond to tags.
% The elements of that cell matrix is a sparse matrix, where the rows
% are feature functions and the columns are... |
% EventMD
% September 2017
clear all; close all;
pos = [0.25, 0.25; 0.75, 0.25; 0.25, 0.75; 0.75, 0.75];
vel = [0.21, 0.12; 0.71, 0.18; -0.23, -0.79; 0.78, 0.1177];
singles = [1, 1; 1, 2; 2, 1; 2, 2; 3, 1; 3, 2; 4, 1; 4, 2];
pairs = [1, 2; 1, 3; 1, 4; 2, 3; 2, 4; 3, 4];
sigma = 0.12;
t = 0.0;
ts = [0];
n_events = 10^5... |
function K = matrix_unroll(A,m)
n = length(A);
[Ai,Aj,Av] = find(A);
Kr = (m+1)*n;
Knz = m*nnz(A)+(m+1)*n;
Ki = zeros(Knz,1);
Kj = zeros(Knz,1);
Kv = zeros(Knz,1);
Ki(1:n) = 1:n;
Kj(1:n) = 1:n;
Kv(1:n) = 1;
% si = n;
ei = n;
for i=1:m
si = ei + 1;
ei = ei + n;
Ki(si:ei) = ((1:n) + ... |
function As = rand_stable(dim)
Temp = rand(dim);
M = max(svd(Temp));
As = Temp/(M + 0.02); |
function lambda = get_fraunhofer_line(name)
% INPUT
% name: Fraunhofer line name
% OUTPUT
% lambda: wavelength
data = {'h', 404.7; 'g', 435.8; 'F''', 480.0; 'F', 486.1; 'e', 546.1; 'd', 587.6;
'D', 589.3; 'C''', 643.8; 'C', 656.3; 'r', 706.5};
for i = 1:size(data, 1)
if strcmpi(name, data{i, 1})
... |
%% a) 3 peças em 5 serem defeituosas
n = 5; %nºpeças
k = 3; %nº peças defeituosas
p = 0.3; %probabilidade de ser defeituosa
N = 1e5; %nºexperiências
%analiticamente
probAnalitica = factorial(n)/(factorial(k)*factorial(n-k))*(p^k)*((1-p)^(n-k))
%simulacao
experiencias = rand(n, N)<0.3;
sucessos ... |
close all;
clc;
clear all;
n=0:127;
fm=input(' Enter the frequency of modulating signal = ');
fc=input(' Enter the frequency of the carrier signal =');
Am=2,Ac=5;
x1=Am*cos(2*pi*fm*n/128);
subplot(211);
plot(n,x1,'m');
comet(n,x1);
hold on;
x2=Ac*cos(2*pi*fc*n/128);
plot(n,x2,'k');
comet(n,x2);
x=x1.*x2/Ac+x2;
subplot(... |
function varargout = ControllerDesignTool(varargin)
% Author: David Orn Johannesson, davidj11@ru.is
% Reykjavik University, 2015
%
%
% CONTROLLERDESIGNTOOL MATLAB code for ControllerDesignTool.fig
% CONTROLLERDESIGNTOOL, by itself, creates a new CONTROLLERDESIGNTOOL o... |
%Title: batch_col_space(col_space,in_files,out_files)
%Author: Timothy Sheerman-Chase
%Date: 8 October 2000
%Description: This m file is designed to open files and feel them to the pictoyuv routine.
%This is usually the first step in building an SCDM as you need a lot of pixels.
%This outputs rgb files into the ... |
%Drill Tip Calibration Test
%CISC 330 - Computer Integrated Surgery
%Assignment 3
%Grace Pigeau 10187678
%
%Purpose: Test the accuracy of the drill tip calibration function
function DrillTipCalibration_test(truth)
trialCount = 1;
amntRight = 0;
%for range of 20, 40, 60, and 80 degrees
for ix = 20:20:... |
%Create MOS output file
close all
clear all
clc
% load('Combined_Results.mat')
% load('Results_v7.mat')
% load('Results_v8_MAD_STD_2nd_outliers_removed.mat');
% load('Results.mat')
load('Plotting_Data_Anon_No_Outliers.mat')
load Full_Source_filelist.mat
% load Sets_filelist.mat;
for n = 1:length(filelist)
file_fol... |
function score = askQuesitons(numQs, showPlot)
%% Quiz the model for n questions
global p;
% preallocate
score = cell(p.maxItems,numQs);
% ask a matrix of questions: cardinality by numQuestions
fprintf('Start testing: %d * %d questions\n', p.maxItems, numQs)
for cardinality = 1:p.maxItems
fprintf('%d', cardinality... |
classdef (Enumeration) TYP_RES_PRESOAK_PROG_REQ_MMI < Simulink.IntEnumType
enumeration
RES_NO_REQUEST(0)
ONE_TIME_REQ(1)
EVERY_TWO_HOURS_REQ(2)
RES_NOT_USED(3)
end
end
|
%% Simulation settings
t_1 = 0; %starttime
t_final = 1; %endtime
dt = 1e-6; % used in DATE 2016 |
function path = grFindMaximalLengthPath(nodes, edges, edgeWeights)
%GRFINDMAXIMALLENGTHPATH Find a path that maximizes sum of edge weights.
%
% PATH = grFindMaximalLengthPath(NODES, EDGES, EDGE_WEIGHTS);
% Finds a greatest geodesic path in the graph. A path between two nodes
% is a succession of adjacent edg... |
R = zeros(10,1);
FCs = linspace(31000,39000,10);
for m = 1:10
fc = FCs(m)
main
R(m) = devPercentCorr
end |
function res=source_integral(params, grid, k, qdeg);
%B=[grid.JIT(k,:,1);grid.JIT(k,:,2)];
f=@(lcoord) source(lcoord, params, grid, k);
res=triaquadrature(qdeg,f)*2*grid.A(k);%2*grid.A is jacobian determinant
end |
% ioARMSimWiFly = serial('COM4','BaudRate',57600);
filename = 'originalMap.txt';
% filename = 'Map1.txt';
[XY,Ramp_Center,Ramp_Entrance,Ramp_Exit,Target] = Read_Map_File(filename);
% h2 = figure(3);
% plotLegend(h2);
h = figure(2);
obj = SetGetCommand(serial('COM6','BaudRate',57600));
obj.saveFigure(h, h);
obj.storMa... |
function plotFastestSlowestImages(timeResultsHop)
rng(0);
timeResultsHop = changeResults(timeResultsHop, 'name', @(r) changeT0Name(r));
%% fastest model
t0Results = filterResults(timeResultsHop, @(r) strcmp(r.name, 'caffenet_fc7-bipolar0-hop_t0-libsvmccv'));
t0Results = collapseResults(t0Results);
fastestModel = t0Res... |
function Result = simulate_devices_with_dsm(hObject, Devices, Frequency, Time)
%SIMULATE_DEVICES_WITH_DSM führt die eigentliche Simulation durch (inkl. DSM)
% RESULT = SIMULATE_DEVICES_WITH_DSM (HOBJECT, DEVICES, TIME) führt die
% eigentliche Simulation mit DSM aus. Dazu wird über jeden Zeitschritt
% (gemä... |
function SFBM_draw(DataIn,DataOut)
P=DataIn{1};
U=DataIn{2};
T=DataIn{3};
R=DataIn{4};
X=DataIn{5};
S=DataIn{6};
SF=-DataOut{1};
BM=-DataOut{2};
THETA=-DataOut{3};
Y=-DataOut{4}*1e3;
xs=DataOut{5};
L=X(end);
h=L/100;
figure(1)
set(gcf,'Position',[20 50 800 900]);
subplot(3,1,1)
% pbaspect([... |
function AIC = AIC(loglik, logparahat)
%AIC returns the Akaike information criterion of clustering
% to choose the optimal number of clusters, see Guo and Landis (2017)
%
% AIC = 2*M - 2 * logP(Y_1,...,Y_n|theta^, M)
%
%In functional clustering with nClusters = K
%
% M = 5*K
% logP(Y_1,...,Y_n|theta^, M)... |
function x = findroot(hL,hR)
%format long
%x0=2.9579; % for hL=1,hR=0.5
x0=9.3538;
hL = 10;
hR = 5;
x = fzero(@(x) shock_nondry(x,hL,hR),x0); |
function out = G2(xi)
out = xi;
p = xi(1:3);
v = xi(4:6);
R = reshape(xi(7:15),[3 3]);
q = xi(16:18);
t = xi(19);
[pd,vd,ddot_pd] = reference(t);
e = [p-pd;v-vd];
x = R'*rd(ddot_pd,e);
if D2(xi)
out(16:18) = qminV2(x);
end
end |
function [filename, userCanceled] = uigetimagefile_v2(varargin)
% UIGETIMAGEFILE Open Image dialog box.
%
% This is a private copy of IMGETFILE to be used by DAStudio. The file
% filter in our case is fixed and much simpler than the one used by
% IMGETFILE. We are interested in common image types which are use... |
% rgb to grayscale conversion
% eqn:- grayscale value at (i, j) = 0.2989 * R(i, j) + 0.5870 * G(i, j) + 0.1140 * B(i, j);
% input from user
img=imread('rgb.jfif');
[M, N, Z]=size(img);
gray_img=zeros(M, N, 'uint8');
x=input('x');
y=input('y');
z=input('z');
for i=1:M
for j=1:N
gray_... |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copyright 2012 Analog Devices, Inc.
%
% 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:/... |
tic();
% disp0_1 = parsePfm('../data/disp0.pfm');
disp0_1 = load('../data/cable_disp.mat');
disp0_1 = disp0_1.disparity;
picture_left = im2double(imread('../data/im0_cable.png'));
disp0_1(disp0_1 == Inf) = 0;
%%Parameters using camera calib
f = 3962.004;
doffs = 107.911;
baseline = 237.604;
mmperpixel = 0.005196629; %... |
function bounds = get_bounds(r)
%bounds = zeros(3,2);
% Use new mode to determine bounds - baesd on values stored in the structure
if isfield(r.all,'tabs_acute_1')
bounds(1,:) = [r.all.tabs_ctrl_1 r.all.tabs_ctrl_2];
bounds(2,:) = [r.all.tabs_acute_1 r.all.tabs_acute_2];
if ~is... |
function [msfc,ws,ol,image_name,xlms,ylms] = msfcFunc()
%enter your value in pixels per meter here:
pxpm= 190
msfc = 1/pxpm
%enter the size of your subwindow for tracing in meters
ws = 2
% what fraction of the window size do you want to have overlap on
% each side?
ol = (1/8)*ws
% what is the name of your image
im... |
function dx = odefun_stance_dyn (t, X, leg, params)
%% ODEFUN_STANCE_DYN
%% Read constant parameters
l1max = leg.l1max;
Ksp = leg.spring.Ksp;
Kd = leg.damper.Kd;
g = leg.g;
%% ------------- Extract State --------------------
t
l1 = X(4);
dl1 = X(8);
%% ------------ Input Forces ---------------
% Damper
Fd = Kd*dl1;
... |
function add_layer_tuberculosis(object,event,h)
%ADD_LAYER_TUBERCULOSIS Summary of this function goes here
% Detailed explanation goes here
len = length(h.tuberculosis_layers);
h.tuberculosis_layers(len + 1) = tuberculosis_layer;
h.tuberculosis_layers(len + 1).name = ['layer_',num2str(length(h.tuberculosis_layers),'%... |
function varargout = sweeplot(varargin)
% MvdM evoked potential viewer for open ephys data
%
% add folder that contains this (.m and .fig) to path!
%
% user configurables:
%
% params.decimateFactor = 30;
% params.timeWindow = [-0.05 0.1]; % time window for viewer, centered on event times
% params.sweepChannel = 0; % I/... |
function Re =flowcal(v,a,T)
c=343;
m=v*0.447/atmosisa(a);
u=muCalc(T);
Re=1.12*v*0.447*6.4/u;
disp(u)
disp(Re)
disp(m)
end
|
function boosterlin
% Booster soleil lattice w/o ID
% Lattice definition file
% Perfect lattice no magnetic errors
% Compiled by Laurent Nadolski and Amor Nadji
% 09/01/02, ALS
% Controlroom : set linearpass for quad (closed orbit)
global FAMLIST THERING GLOBVAL
GLOBVAL.E0 = 2.75e9; % Ring energy
GLOBVAL.LatticeFi... |
function [out] = myGlobalAppearanceMatrix(flag1,appr1,flag2,appr2,w_f)
k1 = find(flag1'); k2 = find(flag2');
w = zeros(8,8);
out = 0;
for i = k1
for j = k2
w(i,j) = w_f(abs(dirDiff(i, j))+1);
out = out + w(i,j) * sum(min([appr1(i,:); appr2(j,:)]));
end
end
out = out / sum(w(:)) - 0.5;
end |
function Button = EDMMenu(PVName, x, y, varargin)
% Defaults
FontSize = 14;
FontWeight = 'bold'; % 'medium', 'bold'
FontName = 'helvetica';
Width = 70;
Height = 20;
for i = length(varargin):-1:1
if ischar(varargin{i}) && size(varargin{i},1)==1
if strcmpi(varargin{i},'FontSize')
FontSize = ... |
%%% Averaging T S and Neutral D over a length of time in the Weddell
%%% for the Iter133 2013-2018 5day carbon data
%%% I'll average over a specified length of time, and a specified region
clear all
load('/local/projects/bSOSE_carbon_Ben/Iter129/grid.mat', 'hFacC', 'RAC', 'DRF');
volume = zeros(size(hFacC));
%%
de... |
%% a: Load audio and Take 5 Secons of That
[audioA,fs]=audioread('/Users/user/Desktop/MT_94109205_3/Dvorak-Cello Concerto in B minor Op. 104.wav');
audioAOut = audioA(18.5*fs+1 : 23.5*fs);
clear audioA;
audiowrite('/Users/user/Desktop/MT_94109205_3/main_signal.wav',audioAOut,fs);
%% b: y[n] = x[n] + 0.5 * x[n-1]
% x[n... |
function [pos] = get_mat_pos(M)
%this function gets the ratio of the SUM OF SQUARES of the positive
%eigenalues to the sum of squares of all eigenvalues of the
%SYMMETRIC part of the matrix M (equivalent to ignoring the imaginary part
%of the eigenvalues of the original M)
if size(M,1)~=size(M,2)
error('input ma... |
function rgbROI=CircleMod2(ImageX,radius,centre)
img = imread('6.jpg');
grayimg = rgb2gray(img);
[imgW,imgH] = size(grayimg);
t = linspace(0, 2*pi, 50);
% r = 150; %°ë¾¶
% c = [300 300]; %Ô²ÐÄ×ø±ê
BW = poly2mask(radius*cos(t)+centre(1), radius*sin(t)+centre(2), imgW, imgH);
rgbmas... |
letters=input('Insert Letters : ','s');
letters=upper(letters);
countLetters=zeros(1,26);
for k=1:length(letters)
countLetters(char(letters(k))-64)=countLetters(char(letters(k))-64)+1;
end
count=0;
xat=[];
for k=1:26
count=countLetters(k);
for kk=1:count
xat=strcat(xat,'x');
end
if count > 0... |
%% Set layer to first conv layer
layer = 2;
name = net.Layers(layer).Name
%% Use deepDreamImage to visualize the 36 learned features
channels = 1:36;
I = deepDreamImage(net,name,channels, ...
'PyramidLevels',1);
%% Show the learned features
figure
I = imtile(I,'ThumbnailSize',[64 64]);
imshow(I)... |
function MBR_main(buffer_cinemri3,rangey,rangex,referenceFrame,numSkip,numPreContrast_bld,numPreContrast_tiss,noi,slice,upsample_flag,upsample_factor)
temp=strcat('Output1/',int2str(slice));
mkdir(temp)
cinemri1=buffer_cinemri3(:,:,:);
[RV LV]=FindLVRV(cinemri1);
x=floor(mean([RV(1),LV(1)]));
y=floor(mean([R... |
%% DESCRIPTION
% this example shows a rectangular grid in 2D, with all fixed
% boundaries, and external forces applied at random locations.
% spring compression is allowed, and all springs are initially
% at their rest lengths. best solver algorithm/objective seems
% to be anneal/maxforce for this scenario.
%%
addpa... |
function rate = getErrorRate(y,h)
datasize = length(y);
index = find(h ~= y);
rate = length(index)/datasize;
end |
outs = [];
for i=1:18
row = real_res(i, :);
filt_row = mean(row);
outs = [outs; filt_row];
end
x = [0.5:0.2:3.9];
plot(x, outs) |
%%%noisy image SR+denoise 0607
% clear all;
%
% input = imread('ted.bmp');
% input2 = im2double(input);
%
% [x,y,C] = size(input2);
% if C == 3
% im_ycbcr = rgb2ycbcr(input2);
% else
% im_ycbcr = input2;
% end
% img = im_ycbcr(:,:,1);
%
% img_1 = rgb2gray(input); %%int
%
% intImage = integralImage(img_1);... |
function [ xPred,vbClustRes, postPred ] = bayesianGMM( x,X,K )
%BAYESIANGMM - function that returns conditional posterior predictive for a VB-GMM
% INPUTS
% x = [nGiven x dimGiven] data with missinkg features
% X = [nOrig x dimOrig] original data with full features to cluster
% K = number of clusters (note in Bayesian ... |
function y = yf(x, A, b,L,lamda)
y = (1/(2*L*lamda))*(norm(A*x-b))^2;
end
|
function parameters=XuReadJsonc(json_file_name)
%parameters=XuReadJsonc(json_file_name)
%This function have potential bugs
%Please do not write the config file in the following format
%1. // or /* or */ in contents
%example: "b":{ // comments
% // comments
% "c": [1, 2, /*comments*/ 3],
% "d": "s... |
function HiLo(basename,a_low,a_high,range,channel)
% APPLIES LOWPASS/HIGHPASS FILTERING TO IMAGE SERIES
%
% basename: Basename of data series
% a_low: Lowpass parameter (typically 1-4)
% a_high: Highpass parameter (typically 500-5000)
% range: Ima... |
function histtest
m=10; s=3;
x=m+s*randn(100);
xobl=x(:);
mobl=mean(xobl); sobl=std(xobl);
fprintf(' \n m = %8.3f - zdana wartosc oczekiwana',m);
fprintf(' \n mobl = %8.2f - srednia',mobl);
fprintf(' \n s = %8.2f - zadane odchylenie standardowe',s);
fprintf(' \n sobl = %8.2f - oszacowanie odchylenia standardo... |
%% Transition probability matrix를 역산해 구하는 방법
clear
maxk = 1;
maxd = 10;
trial = 100;
genenum = 10;
kEucDist = zeros(maxk,trial,genenum,maxd);
kEvolDist = zeros(maxk,trial,genenum,maxd);
kRawPdf = cell(maxk,trial,maxd);
kNewPdf = cell(maxk,trial,maxd);
%% Reference sequence
i = 1;
temp = getgenbank... |
function [ res ] = EF_GradientVectorCalc( dLab1, dLab2 )
%GRADIENTVECTORCALC Perkalian titik dari vektor gradien
% Masukan: dLab1: Vektor gradien 1
% dLab2: Vektor gradien 2
% Luaran: res: Hasil perkalian titik antarvektor gradien
res = dot(dLab1,dLab2);
end
|
function [x_RO] = RO_ccp(dataset_1,dataset_2,data_rank,c,b)
[n1,num_rv]=size(dataset_1);
n2=size(dataset_2,1);
d=length(c);
A_c=d;
A_r=num_rv/d;
% phase 1
sample_mean=mean(dataset_1);
% dataset_row_split=zeros(n1+n2,A_c,A_r);
dataset_p1_row_split=zeros(n1,A_c,A_r);
... |
% Simple function to obtain time of code in hrs mins sec
function normaliseTime(runtime)
if runtime < 60
disp(['Run time = ' num2str(runtime) ' secs']);
end
if runtime > 60 && runtime < 3600
disp(['Run time = ' num2str(runtime/60) ' mins']);
end
if runtime > 3600
disp(['Run time = ' num2str(runtime/3600) '... |
function [AccuracyK, dist, results2,results_f] = KNN(K,numWriters,alpha1,alpha2,end_training_document,start_training_document,end_testing_document,start_testing_document)
%% Measuring distance between each test document with every training Document
dist = zeros(size(alpha1,2), size(alpha2,2));
for i = 1:size(alpha2,... |
%ENSURE THIS FILE IS IN THE SAME LOCATION AS "concept.m" AND "interpolation_data.xlsx"
%Script is run each time "Calculate" in GUI is pushed
humid = get(handles.edit1, 'String'); %Reads user value for humidity
humid = str2double(humid); %Converts string to numerical value
temp = get(handles.edit2, 'String'); %... |
function [imdsTrain,imdsValidation] = CNNDataPrepareAllAreas(validation_percent)
%% Load Dataset
% set dataset path
imds = imageDatastore('CNNDATA\', ...
'IncludeSubfolders',true,'labelSource','foldernames');
% calculate number of datapoints
num_datapoints = numel(imds.Files);
%% Display data
... |
clear all;
close all;
ts=0.001;
sys=tf([1.05],[6.8e-6 2.47e-3 0.7925]);
dsys=c2d(sys,ts,'z');
[num,den]=tfdata(dsys,'v');
u_1=0.0;u_2=0.0;
y_1=0.0;y_2=0.0;
x=[0,0,0]';
error_1=0;
for k=1:1:100
time(k)=k*ts;
kp=0.1094;
ki=67.6368;
kd=0;
rin(k)=1;
u(k)=kp*x(1)+kd*x(2)+ki*x(3);
if u(k)>=10
u(k)... |
function val = objfunc(p,yi,ncams)
%Import problem structure
env = environment_generate('mini_0705.mat');
datax = env.datax;
datay = env.datay;
dataz = env.dataz;
obsta = env.obsta;
annot = env.annot;
ldata = length(datax);
b =... |
% this just runs a bunch of simulations
function multi_run_stats=make_multi_run_stats(runstuff,params,protoc)
num_sims=runstuff.num_sims; % number of simulations
rng(runstuff.seed) % random number seed set
multi_run_stats.days_asymp_lax=zeros(num_sims,1);
multi_run_stats.days_asymp_strict=zeros(num_sims,1);
multi_run... |
function newalphabet = groupSymbols(fonte)
fonte = fonte(1:numel(fonte)-1);
alph = strings(numel(fonte)/2, 1);
j = 1;
for i = 1:2:numel(fonte)
a = mat2str(fonte(i));
b = mat2str(fonte(i+1));
alph(j) = strcat(a,b);
j = j + 1;
end
newalphabet = unique(alph);
%disp(numel(fonte))
%if (mod(numel(fonte), 2... |
function [Ave_Payoff,Payoffs,ExBoundary_root,ExBoundary_exh] = Performance(Method,Weights,Data,r,Vol_Window,Initial_Vol,MARKER_Exer_Boundary,Settings, Ticker, MARKER_plot, method, K)
% Calculating realized volatility rescaled by dt.
Vol_Data = Volatility_Data(Data,Vol_Window,Initial_Vol,Settings);
ExBoundary_exh = ... |
function [Results,Avg,Params] = load_results(RESULT_DIR,SOLUTION_DIR,DATA_DIR,COND_FILE,META_FILE,TRIAL_MODALITY,WRITE,FLAG_WRITECV,CountRadius)
% Load metadata
seedHoldSubj = csvread(fullfile(RESULT_DIR,COND_FILE));
if size(seedHoldSubj, 2) < 3
tmp = zeros(size(seedHoldSubj,1),3);
a = 3 - size(seedH... |
function stim_fef_dots(optstr,w,objID,arg)
%function stim_fef_dots(optstr,w,objID,arg)
%
% showex helper function for 'fef_dots' stim class
%
% Each helper function has to have the ability to do 3 things:
% (1) parse the input arguments from the 'set' command and precompute
% anything that is necessary for that stimulu... |
function clear_cache()
%Clears the hard drive read cache used by load_image()
%
% === Notes ===
% This function is not strictly necessary but is included for
% convenience. The cache used by load_image() can be cleared by calling
% that function and specifying the option 'clear_cache' to be true. This
% fun... |
clear
close all
clc
figure()
hold on
rng(1)
rotation = [cos(pi/4),-sin(pi/4);sin(pi/4),cos(pi/4)];
sigma =rotation*[1,0;0,0.1]*rotation';
true_mean = [2;2];
number_of_particles = 20;
particles = mvnrnd(true_mean,sigma,number_of_particles);
sigma = cov(particles);
plot(particles(:,1), particles(:,2)... |
clear;
%% Distance modified multiplicatively
pn = 128; % dimensionality of spaces (no. of grid points)
pN = 1:4:31; % ensemble sizes
iters = 20; % number of iterations with each configuration
cs_parms = [0.1 1 10]; % parameters fo cs
cs_func = @make_cs_exp_alph... |
classdef (Abstract) OrigRatioUpdaterAbstractError < OrigRatioUpdater
% OrigRatioUpdaterAbstractError -- abstract class for adaptive origRatio updating
% via model error, its exponential smoothing and linear transfer to origRatio
%
% Core method update() updates OrigRatioUpdater's state and returns the ratio
% of popu... |
classdef LocalPooler < handle & featpipem.pooling.GenericPooler
%LOCALPOOLER Multiple local pooling
properties
subbin_norm_type % 'l1' or 'l2' (or other value = none)
norm_type % 'l1' or 'l2' (or other value = none)
post_norm_type % 'l1' or 'l2' (or other value = none)
end
properties(Set... |
clear,clc
global xmean xcov xsd corrMatrix
xmean=[120000 160000];
xcov=[0.3 0.3];% coefficient of variation
xsd=xmean.*xcov;
corrMatrix=[1 0
0 1];
DP = [75714.45371 73441.94686
48522.30988 152912.501];
dp2 = [
94163 67805
50567 151120] ;
% 0 94163 67805 0.99
% 0 94419 68718 1
% 0 4779... |
classdef (Sealed) GraphUtil < handle
%GRAPHUTIL Graph utilities.
% This is a utility class containing useful static methods related to
% Graphs.
%
% See also: GRAPH, GRAPHFORMAT.
%======================== PROPERTIES ==============================
properties (Constant, GetA... |
%Task3
%3a
%balance equations
%state (10^-6): (1)π0 - (180)π1
%state (10^-5): (180+20)π1 - (1)π0 - (40)π2
%state (10^-4): (40+10)π2 - (20)π1 - (20)π3
%state (10^-3): (20+5)π3 - (10)π2 - (2)π4
%state (10^-2): (2)π4 - (5)π3
A = [1 -180 0 0 0
-1 180+20 -40 0 0
0 -20 4... |
function new_obj = dsp__add_percent_of_trials_per_day( obj )
days = unique( obj('days') );
new_obj = Container();
for i = 1:numel(days)
extr = obj.only( days{i} );
n_trials = shape( extr, 1 );
percent = ( 1:n_trials ) / n_trials;
extr.trial_stats.percent_per_day = percent(:);
new_obj = new_obj.append( extr )... |
clc,clear all, echo off
fc=imread('background.jpg');
[r,c,d]=size(fc);
figure(11)%background/hawaii sunset maui beach
image(fc)
disp('pause')
pause
fc1=imread('yippee.jpg');
[r1,c1,d1]=size(fc1);
figure(211)%yippee
image(fc1)
disp('pause')
pause
r,r1,c,c1,
% fc is maui beach
% fc1 is yippee
redfc... |
%This code plots the estimated responses with error bands as well as the
%true responses for one MC run
inds=setup.number_of_draws/setup.keep_draw;
indices_for_draws=unidrnd(inds,100,1);
for kk=1:length(indices_for_draws)
size_of_shock=-1;
shock_contemp=zeros(setup.size_obs,1);
shock_cont... |
% multi layer perceptron
% XOR input for x1 and x2
input = [0 0 0; 0 1 0; 1 0 0; 1 1 0;1 0 1;1 1 1;0 1 1;0 0 1];
% Desired output of XOR
output = [0;1;1;0;0;1;0;1];
% Initialize the bias
bias = [-1 -1 -1 -1];
% Learning coefficient
coeff = 0.7;
% Number of learning iterations
iterations = 2000;
% Calculate weights ran... |
function filename = deletePunctStr(textFileIn)
% Replaces all punctuation in textFile with ' '
filename = int2str(floor(10000*rand));
nid = fopen(filename, 'w');
newArray = [];
space = ' ';
textFile = char(textFileIn);
[m n] = size(textFile);
for i = 1:n
if (textFile(i) == '.')
newArray(i) = space;
... |
global ts kds kps tds dtds
% print thetad, theta
figure(2);
clf
tds_ode = x(:, 5:6)';
hold on;
plot(t, r2d(tds_ode(1,:)), t, r2d(x(:,1)))
plot(t, r2d(tds_ode(2,:)), t, r2d(x(:,2)))
if sum(size(tds))
plot(ts, r2d(tds(1,1:length(ts))), ts, r2d(tds(2,1:length(ts))));
end
legend('\thetad_1', '\theta_1', ...
'\t... |
function Q = euler2rotmat(p,r,h)
%
% Q = euler2rotmat(p,r,h)
% or
% Q = euler2rotmat(prh)
% Make a rotation (or direction cosine) matrix out of sets of Euler angles,
% pitch, roll, and heading.
%
% Inputs:
% p is the pitch angle in radians.
% r is the roll angle in radians.
% h is the head... |
function [offset] = calculate_cr_offset(start_time_txt)
%CALCULATE_CR_OFFSET Summary of this function goes here
% Detailed explanation goes here
fileID = fopen(start_time_txt, 'r');
radar_time_str = split(fgetl(fileID));
radar_time_str = split(radar_time_str{2}, ':');
radar_time = str2num(radar_time_str{end});
cam... |
function [Q,J,F,T,I,V,E] = spinv(A,varargin)
% SPINV Compute a sparse factorization of the Moore-Penrose pseudoinverse A⁺
% of a sparse matrix A. This is useful for solving
% under-and-over-constrained systems Ax = b: where A is m by n with
% rank r < min(m,n). Then to solve the system:
%
% x = E*(V*(I... |
function h = hypothesis(theta, x)
h = theta(1) + theta(2) .* x;
end |
times_symbolic = csvread('times-symbolic.csv', 0)
times_autograd = csvread('times-autograd.csv', 0)
figure;
h1 = histogram(times_symbolic);
hold on
h2 = histogram(times_autograd);
xlabel('Time taken to determine $g(x) = \frac{df}{dx}$ and evaluate g(1.5) \, [s]', 'Interpreter', 'Latex');
ylabel('Frequency');
legend(... |
function varargout = TSfielddetails(varargin)
% TSFIELDDETAILS M-file for TSfielddetails.fig
% TSFIELDDETAILS, by itself, creates a new TSFIELDDETAILS or raises the existing
% singleton*.
%
% H = TSFIELDDETAILS returns the handle to a new TSFIELDDETAILS or the handle to
% the existing singleto... |
% WaitForScannerTrigger.m
function WaitForScannerTrigger(ScannerConnected, windowPointer, fmriCode)
% First image is taken when scanner sends a '5%' to the computer. This
% script pauses the rest of the experiment from starting until it recieves
% the first EPI. Adapted from Jonas Kaplan fMRI
% tutorial by Matt H.
... |
% % % clear all
% % % clc
% % % %[pathstr, name, ext] = fileparts(which('px_toolbox'));
% % % %Textfile = '/data/Experiment/px_function/Template/MNI_Coordinates_264.txt';
% % % P = spm_select('ExtFPList','/Volumes/Data/data/pengfeixu/DataAnalysis/young/TaskYoung/NoSeg_GlobCorr/Analysis/group_filter2/Interaction', '^Sub... |
function [Kalman, TranMX, DistMean, DistCov, State0, StateCov0] =...
DSSUpdate(Y, TranMX, DistMean, DistCov, MeasMX, ObseCov, State0, StateCov0)
%DSSUpdate returns the fitting information of one subject (stored in Kalman)
%and construct the prior information of state-space model for next subject.
%
%Input:
% -Y: ... |
%This function finds the key pressed and stores it with setappdata so it is
%available to the main function.
function getKey(~, eventDat)
keyPressed = eventDat.Key; %recording the keys pressed to a variable
setappdata(0, 'keyPressed', keyPressed); %save key so it can be used in other functions |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.