text stringlengths 8 6.12M |
|---|
%TrainingData_File='csv_data/ACTEWAGL/train_wd.csv';TestingData_File='csv_data/ACTEWAGL/test_wd.csv'; FileName='input_data/ACTEWAGL/helm_input_wd';
%TrainingData_File='csv_data/ACTEWAGL/train_lwd.csv';TestingData_File='csv_data/ACTEWAGL/test_lwd.csv'; FileName='input_data/ACTEWAGL/helm_input_lwd';
%TrainingData_File='c... |
%% Panair mesh creation
%
% Adrien Crovato
% ULg 2015-2016
%
% This scripts reads airfoil data for panair/aero wing mesh creation
%% Initilization
clear all;
close all;
% Folders and paths
nAirf = 3; % number of airfoil used to generate the wing
fname = cell(1,nAirf); % name of the airfoils data file
... |
function f = gaussian_1d(T, a, mu, sig)
% function f = gaussian_1d(T, mu, sig)
%
% Create a gaussian 1d function with amplitude and without normalizing.
%
% INPUTS
% T: Length of time window
% a: Amplitude
% mu: Mean
% sig (sigma): Variance
% f = exp(-x.^2/(2*sig^2)-y.^2/(2*sig^2... |
% "Bad" system of linear equation:
% 1.
A=[0.789 0.563;0.913 0.659];
fprintf('cond(A)=%d ; det(A)=%d\n',cond(A),det(A))
% 2.
A = [4.1 2.8; 9.7 6.6]; b = [4.1 ; 9.7]; b1=[4.11 ; 9.7];
cond(A,1)
cond(A,2)
cond(A)
cond(A,"inf");
x = (A \ b)'
x1 = (A \ b1)'
|
% Name: Zheng Wen
% USC ID: 7112807212
% USC Email: zwen1423@usc.edu
% Submission Date 2/11/2020
function cube = MBVQCube(r,g,b)
if((r+g)>(255/255))
if((g+b)>(255/255))
if((r+g+b)>(510/255))
cube='CMYW';
else
cube='MYGC';
end
else
cube='RGMY... |
%% MATLAB for Brain and Cognitive Scientists (MIT Press 2017)
% mikexcohen@gmail.com
%
% This script contains solutions and tips for most exercises in the book.
% If you are struggling with an exercise not in this list, email me with an
% explanation of what you've already tried and what you need help with.
%% Chapter... |
%% Comparison of FT of images
% display images
X = imread('leaves.jpeg'); % picture of leaves - high spatial frequency
Y = imread('ceiling.jpg'); % picture of ceiling - low spacial frequency
% display grayscale image
figure(1)
G = rgb2gray(X);
imagesc(G)
colormap(gray(256))
figure(2)
P = rgb2gray(Y);
imagesc(P)
color... |
clc
clear all
close all
%Checking Linearity%
n = 0:1:6;
x1 = [0 2 3 4 5 6 9]; %Discrete signal x1[n];
x2 = [2 5 6 3 5 2 5]; %Discrete signal x2[n];
y1 = x1.^2;
y2 = x2.^2;
x3 = x1 + x2;
y3 = x3.^2;
ycheck = y1 + y2;
stem(n,y3 , 'r'); hold on;
stem(n,ycheck,'b');
legend('x1[n] + x2[n]','y1[n] + y2[n]');
|
% compile.m should work for Linux and Mac.
% To Windows users:
% If you are using a Windows machine, please use the basic convolution (fconv.cc).
% This can be done by commenting out line 13 and uncommenting line 15 in
% compile.m
compile;
% load and visualize model
% Pre-trained model with 146 parts. Works best for f... |
function GetTrainingData(all_ftypes,np,nn)
DirNameF = 'TrainingImages/FACES/';
DirNameNF = 'TrainingImages/NFACES/';
im_sfnF = 'FaceData.mat';
im_sfnNF = 'NonFaceData.mat';
f_sfn = 'FeaturesToUse.mat';
LoadSaveImData(DirNameF, np, im_sfnF);
LoadSaveImData(DirNameNF, nn, im_sfnNF);
ComputeSaveFData(all_ftypes, f_sf... |
% We want to create 44,100 samples for every second of audio data. This is a commonly used sampling rate for music files.
global Sampling_Rate
Sampling_Rate = 44100;
% Call the synthesizer function shown below in order to put some audio data
% into the variable named "sound".
sound = Synthesize(475, 0.8, 4);
% Use th... |
function fh = fastNodePlot(neuron, micronFlag)
% FASTNODEPLOT Gets the NeuronApp 3d plot w/out the app
% INPUTS:
% neuron
% OPTIONAL:
% micronFlag [true] microns or viking pixels
% fh figureHandle
%
% 18Aug2017 - SSP - created
fh = figure();
... |
% Calculate spectrum from multi-trial uniformly sampled data mX
% mX is p * len * n_trials array, the sampled data
% aveS is fftlen*p*p matrix
% currently no window function applied
% does not subtract mean value from original data
function [aveS, fqs] = mX2S_ft(mX, fftlen)
mX = permute(mX,[2 1 3]); % conve... |
function[] = discorectangle(w, xycenter, r,facecolor, opacity)
%% Draws a discorectangle.
% Inputs:
% w = width of the discorectangle
% xycenter = 1x2 array containing x,y coordinates of the center of the
% discorectangle
% r = radius of the circle that defines the arch of the semicircular
% portion... |
classdef Result < handle
%RESULT Summary of this class goes here
% Detailed explanation goes here
properties
code = ether.optim.Solver.NeverEvaluated;
derived = [];
parameters = [];
sigma = [];
sigmaType = ether.optim.Solver.NA;
thrown = {};
end
methods
function this = Result(varargin)
if nu... |
function [D_ATL11, D_ATL06, params]=read_ATL11_h5(filename)
II=h5info(filename);
for kG=1:length(II.Groups);
theGroup=II.Groups(kG);
GroupName=theGroup.Name;
groupFieldName=strrep(GroupName,'/','');
clear temp;
for kD=1:length(theGroup.Datasets);
theDataset=theGroup.Datasets(kD);
d... |
close all;clear all;clc
% load('calibrationSession.mat');
I1 = imread('C:\Users\MagicWang\Desktop\StereoVision\Code\opencv\left\left01.jpg');
I2 = imread('C:\Users\MagicWang\Desktop\StereoVision\Code\opencv\right\right01.jpg');
[J1, J2] = rectifyStereoImages(I1,I2,stereoParams);
% figure
% imshow(J1);
disparityMap ... |
% Before running this code, connect to the Arduino using the command
% a = arduino('COM3');
% Note: your COM port number may be different
%% Code to initialize motor5 which is controlled by the external L293 IC
% define pins to control motor5 (L293 chip that is external to motor shield)
motor5.enablePin = 9;
motor5... |
function [success] = compile_mex(name, files, varargin)
directory = pwd;
includes = {};
linkdirs = {};
libraries = {};
for i = 1:2:length(varargin)
switch lower(varargin{i})
case 'directory'
directory = varargin{i+1};
case 'includes'
... |
%%Created on 11/6/2020
%%%Standard incidence
%%%Four equations
%%%Works well with start date March 17, 2020
%%This file solves diffusive coronavirus model using finite element scheme
%%%Initial population data will be used by world data
%%%%%%%%%%%%%%%%%%%%%%%%
%%Run mathematica file Brazil_Border to get a simple b... |
% created by: Zoya Bylinskii, May 2014
% updated Aug 2014
% built on top of code from Tilke Judd
function [score] = scoreModel_parallel(folder, metric, ext, FixationDBCleaned, FIXATIONMAPS, STIMULI, HASH)
files = dir(fullfile(folder, ['*.',ext]));
score = zeros(length(files), 1);
allmapfiles = cellfun(@(x) fullfil... |
time2=1:65;
Xi=Xi(:,:);rXi=rXi(:,:);Xs=Xs(:,:);rXs=rXs(:,:);
Xi=fXi(:,:);rXi=frXi(:,:);Xs=fXs(:,:);rXs=frXs(:,:);
% Xi=normc(Xi);rXi=normc(rXi);Xs=normc(Xi);rXs=normc(rXi);
% Xi=repop(Xi,'-',mean(Xi));rXi=repop(rXi,'-',mean(rXi));
% Xs=repop(Xs,'-',mean(Xs));rXs=repop(rXs,'-',mean(rXs));
Ns=size(Xs,1);Ni=size(Xi,1);
ne... |
function qs = qsat(press, temp)
% Calculate satuated specific humidity
% temp (K)
% press (pa)
Saturation_vapor_pressure = 611 .* exp(17.27.*(temp-273.15)./(temp-273.15+237.3));
qs = 0.622 .* Saturation_vapor_pressure ./ press;
end
|
function [eqs, true_roots] = generate_notensor3_real(cfg, eq, known, unknown)
fprintf('start\n');
case_num = 4;
is_4_std = false;
% projs1 = rand(2, 3);
% R2 = eye(3);
% %generate_cam(prime_num);
%
% [R3,at,bt,ct,dt] = model.generate_cam();
%
% % t2 = randi(100, 3,... |
function m4_5_plot(tt)
axis equal
ylim([0,120]);
for t=tt
[xw,yw,xe,ye,k,distance,T]=m4_5(t);
plot(xw,yw,'.-');
hold on
plot(xe,ye,'x-');
hold on
t
xw(k+1)
yw(k+1)
distance
T
end
set(gca,'XTick',0:5:100);
set(gca,'YTick',0:10:140);
title('·ÂÕæ-Question4');
xlabel('x');
ylabel('y'... |
clc; clf
% physical parameters
T=1.0;
t=0.0;
% numerical parameters
dx=1E-2/1.0;
Nh=1/dx+1;
x=linspace(0,1,Nh)';
tol=1E-15;
dt=0.01*dx;
% initial condition
%un=sin(2*pi*x).^12;
un=(x>=0.35).*(x<=0.65);
plot(x,un,'--r','linewidth',4)
% ***** Consistent Mass matrix ***** %
M=1/6*diag(ones(Nh-1,1),1) + 4/6*diag(ones(... |
% EXERCISE1: basic training and testing of a classifier
% setup MATLAB and the paths
setup ;
paths = localPaths() ;
% error('missing trainLinearSVM');
% --------------------------------------------------------------------
% Stage A: Data Preparation
% --------------------------------------------------------------------... |
function [params,fval] = fit_dsprt_pred(LLR,choice)
% FITS CHOICE DATA TO A SINGLE-HAZARD RATE MODEL WITH LIKELIHOOD WEIGHT AS
% A FREE PARAMETER AS WELL
ub = [1 20];
params0 = [.4 2];
lb = [0 0];
model = @fit_dsprt_min;
opts = optimoptions(@fmincon,'Algorithm','interior-point');
ms = MultiStart('UseParallel','alway... |
disp('It is running. Please wait ...');
clear all;
javaaddpath(pwd);
esmd= esmd4j.Esmd();
% load data
data=load('data\12k\007\B007-0.mat');
Y=data.X118_DE_time(1025:2048);
delt_t = 0.05; % sampling period
t=esmd.init_t(length(Y),delt_t);
%parameters setting:
minLoop=1;
maxLoop=40;
extremeNumR=6; % >=4
jianGeNum = 1; %... |
function d = trim(d,tstart,tstop,varargin)
% trim eye position signal(s)
% 2016-11-13 - Shaun L. Cloherty <s.cloherty@ieee.org>
args = varargin;
p = inputParser;
p.addParameter('debug',false,@(x) validateattributes(x,{'logical'},{'scalar'}));
p.parse(args{:});
args = p.Results; %#ok<NASGU>
t = d.t; ... |
% Impedance and gain of a dipole antenna
freq = 1e9;
k = freq * sqrt(eps0 * mu0);
wavelen = 2*pi/k
% Antenna parameters
L = wavelen*0.5 % length
a = L/(74.2*2.0) % radius
% Antenna impedance
[ Zin V I S Z2 rb re ] = dipolea( freq, L, a );
Zin
% Calculate stationary impedance under the assumption of sinusoidal... |
fileid=fopen('input.txt','r');
n=fscanf(fileid,'%d',1);
A=zeros(n,n);
b=zeros(n,1);
for i=1:1:n
for j=1:1:n+1
if j<=n
A(i,j)=fscanf(fileid,'%f',1);
else
b(i,1)=fscanf(fileid,'%f',1);
end
end
end
fclose(fileid);
disp('Please enter the options')
str=i... |
function [PatientsData] = build_dataset_headSMART(PatientsData)
for pid = 1:length(PatientsData)
pd = PatientsData(pid);
meta = pd.meta;
brains = pd.rota_brains;
brains = brains(:,:,meta.startI:meta.endI);
intensity_mean = pd.intensity_mean;
slices_features = str... |
function params = rna_treino(camadas, x_treino, y_treino, lambda)
% Faz o treinamento da rede neural
% input:
% camada: camada_interna usado no modelo
% x_treino: base que sera utilizada para treinamento
% y_treino: labels para cada amostra de x_treino
% lambda: lambda usada na rede
% output:
% ... |
clc
clear
%for i = 1: 40
%rel_rho(i) = 0.12+ 0.01*(i-1); %relative density vatiable input
%end
%rel_rho = rel_rho'
rel_rho = [0.12;0.3;0.6];
aaaaa = 1
for num_analysis = aaaaa:size(rel_rho,1)
fileID = fopen('implant_new_contact.bdf'); %open file
if fileID == -1 %verify if file name is correct
error(... |
function [Pindices Pids] = get_observed_pairs(BIRDS_DATABASE,PEDIGREE,year)
Pindices = zeros(BIRDS_DATABASE.birds_number,1);
Pids = cell(BIRDS_DATABASE.birds_number,1);
for i=1:BIRDS_DATABASE.birds_number
current_bird = BIRDS_DATABASE.get_bird_by_index(i);
birdID = current_bird.ringNo;
partnerID = PEDIGR... |
%-------------------------------------------------------------------------%
%Filename: w6j.m
%Author: Oliver Johnson
%Date: 6/7/2011
%
% W6J computes the Wigner 6-j coefficients.
%
% Inputs:
% a,b,c,d,e,f - Scalar arguments to the 6-j symbol from the form:
%
% {a b... |
%defineClockEnvironment
%
%This file defines the environment needed to interact
%with the CLOCK component.
%
%The CLOCK component basically gives you a command
%interface to do set the clock rate of the mote
%
%To send packets to a node running CLOCK, first run this file
%and then run one of the other functions in ... |
function InterpolatedImage = ZoomIn16(filename)
image = imread(filename);
InterpolatedImage = image;
for i=1:4
InterpolatedImage = Interpolate(InterpolatedImage, 'rows');
end
for i=1:4
InterpolatedImage = Interpolate(InterpolatedImage, 'columns');
end
outputFilename = strrep(filename,'.', '_interpolated.')... |
function sample=supervisedGibbs(sample, data, labels, params, t)
n=size(data,1);
place=mod(t,params.delta)+1;
sample.num(:,place)=0;
for k=sample.K:-1:1
if sum(sample.num(k,:))==0
sample=removeClassifier(sample,k);
end
end
z=supervisedInitializeZ(sample, data, labels, params, t==1);
sample=sup... |
function [dy] = Mouvement(t,y,alpha,theta,ve,Mi) % y = [R; V; M]
R = y(1:2);
V = y(3:4);
M = y(5);
% Constantes
mu = 3.986*10^14;
cx = 0.1;
rho0 = 1.225;
H = 7000;
Rt = 6378137;
% Calcul des forces
W = (-mu*M/norm(R)^3)*R;
rho = rho0*exp(-(norm(R)-Rt)/H);
D = -cx*rho*norm(V)*V;
gamma = asin(R'*V/(norm(R)*norm(V)))... |
%%%
% Creates Figures on cell bias towards aggreagtes
%%%
addpath('Libraries/Utils')
PROJECT_BASENAME = ['/Volumes/Scratch/Chris/Paper2_Rippling/Paper2/'];
run('ENVS.m')
load([PROJECT_BASENAME, '/data/processed/Development/AllDataTableCsgAinCsgA.mat']);
AllDataTableCsgAinCsgA = AllDataTable;
load([PROJECT_BASENAME, '... |
function [colorLabelIm, textureLabelIm] = compareSegmentations(origIm, bank, textons, winSize,numColorRegions, numTextureRegions)
textureLabelIm=0;
% this method runs about 2 minutes and 10 seconds for coins.jpg. Be patient.
% k-mean by color
%pick a sample first, then pick initial cluster centers from ... |
function [ A ] = MPS_GenerateRandom_left( N, D, d, type )
%type can be real ('real') or complex ('cpx')
if nargin == 3
type = 'cpx';
end
A = cell(N,1);
if strcmp(type, 'cpx')
A{1} = sqrt(0.5)*(randn(D, d)+1i*randn(D, d))/sqrt(d*D^(1/2));
A{N} = sqrt(0.5)*(randn(d, ... |
function aclActionEnum = fromRwx(rwx)
% FROMRWX Returns AclAction enum corresponding to the rwx permission string
% The input character vector can be upper or lower case and unset fields
% should be set to '-' e.g. 'r-x'. In the case of invlaid input logical
% false is returned.
%
% Example:
% % set and aclAction... |
clear all
close all
clc
mDir = pwd;
cd '..'
WorkDir = pwd;
%% LOAD DATA
IDchoices = {'','p01','p02','p03','p04','p05','p06','p07','p08','p09',...
'p10','p11','p12','p14','p15','p16','p18','p19','p20',...
'p21','p22','p23','p24','p25','p26','p27','p28','p29','p30'};
Tchoices = {'','... |
%disconnect zaber stages
function zaberDisconnect
import zaber.motion.Library;
import zaber.motion.ascii.Connection;
global zaber
if ~isempty(fieldnames(zaber))
zaber.connection.close();
fprintf('Closed connection to zaber stages\n');
zaber=struct;
end |
function [paramNames, templateFun, fitFun, reqArgs] = getClassifierParamNames(mdlName)
[paramNames, templateFun, fitFun, reqArgs] = getMLParamNames(mdlName, "Classifiers");
end |
function segmentWhite(file_images)
% file_images: - cell array of strings with filenames or
% - numeric array of image IDs or
% - empty/notexistant to process all images in folder
if ~exist('file_images','var') || isempty(file_images)
file_images = [];
elseif isnumeric(file_images)
nu... |
%Same input as ass.1
price = 11;
strike = 12;
rate = 0.02;
time = 82/252;
%volatility = 0.12;
yield = 0;
callVector = [];
putVector = [];
volatilityVector =[0:0.01:1];
for i=1:length(volatilityVector);
volatility = i;
[x, y] = blsprice(price, strike, rate, time, i, yield);
callVector(end+1)=x;
putVect... |
function p = dewp(testSystem, t)
if nargin==2
testSystem.setTemperature(t);
end
testSystem.init(0)
testSystem.init(1)
testFlash = neqsim.thermodynamicOperations.ThermodynamicOperations(testSystem);
testFlash.dewPointPressureFlash;
p = testSystem.getPressure
clear testFla... |
%% EOSS_global_tradespace_size.m
Nvec = 2:30;
narc_vec = zeros(length(Nvec),1);
bellies = zeros(length(Nvec),1);
factos = zeros(length(Nvec),1);
products = zeros(length(Nvec),1);
for i = 1:length(Nvec)
N = Nvec(i);
narc = 0;
for ni = 1:N
narc_ni = 0;
for ns = 1:ni
narc_ni = narc_ni + stirlin... |
%Oppgave 1 - Practice 10.4
%Before writing the function down, we'll try to define what the function
%would return. We see that the function will return a a looped number given
%the input. Ex.: recurfn(2) will give us 4+4+4+2, as outvar = 4 +
%recurfn(num-1) as long as num < 0.
function outvar = recurfn(num)
if num ... |
function [d]=distance(S,sender,receiver)
d=sqrt( (S(sender).xd-(S(receiver).xd) )^2 + (S(sender).yd-(S(receiver).yd) )^2 ); %Finding nodes in advertiser's range
end |
function [ ldr2hdr ] = Linearization2( ldrtohdr )
%对输入ldrtohdr进行线性延拓,即将1X256扩展为1X32768;
% 这里的输入ldrtohdr是在编码前就计算出的从LDR到HDR的全局色调映射,是最原始的版本的ldrtohdr;
% 这里的输出ldr2hdr可以看作是Linearization函数得到的hdrtoldr映射的反向映射。
ldr2hdr=zeros(1,32768);
ldr2hdr(1)=0;
jj=2;
ii=2;
th=1;
x1=0;y1=0;
x2=ldrtohdr(ii);y2=ii-1;
while jj<32768
if... |
function lfpBool = LFPtest(locName)
cd(locName);
dirTemp = dir('*.txt');
dirTable = struct2table(dirTemp);
fNames = dirTable.name;
if ismember('lfp_no.txt',fNames)
lfpBool = 0;
elseif ismember('lfp_yes.txt',fNames)
lfpBool = 1;
end
|
function Y = uq_Example_Simple_SR_fcn(X)
% UQ_EXAMPLE_SIMPLE_SR_FCN is a simple function where
% Y = 2*X2 - X1^2
Y = 2*X(:, 2) - X(:, 1).^2; |
function calibratePID
%Run this first:
% NIn=connectToUSB6009;
set(NIn,'SampleRate', 100);
set(NIn,'SamplesPerTrigger', 1000); % 10 sec of data
start(NIn) % Record zero concentration
out = getdata(NIn);
% Next present 5ppm
start(NIn)
out(:,2) = getdata(NIn);
% Next present 50ppm
start(NIn)
out(:,3) = getdata(NIn);... |
% Author: Hasan Ibne Akram, Huang Xiao
% Munich University of Technology
% Web: http://www.sec.in.tum.de/hasan-akram/
% Email: hasan.akram@sec.in.tum.de
% huang.xiao@mytum.de
% Copyright © 2010
%
% This is a beta version
%
% DISCLAIMER OF WARRANTY
% This source code is provided "as is" and without warranties... |
classdef OSA < VCE
%OSA wrapper of OSA
properties(Constant)
% Bypassed properties
sigmamu = 30;
sigmamub= 30; % narrow neighborhood width for mean kernel
peso = 10; % weight for wide mean kernel
pesob = 1; % weight for narrow mean kernel
end
properties
cmd_path = '../vce/bin/osa';
end
methods
... |
function [ hfig ] = drawPayoff( obj , ST, cost )
% 画structure的payoff图像
% -------------------------
% 吴云峰,20160120
% 黄勉,20160128,加入 cost
if ~exist( 'ST' , 'var' )
ST = 1.7:0.05:3; % 所有的K的范围
end
if ~exist( 'cost' , 'var' )
cost = 0; % 期权组合成本
end
L = length(ST);
payoff = zeros(L,1);
for i = 1:L
payoff(i)... |
function result = LobattoPoly(x,p)
%LobattoPoly Returns the p+1 Lobatto Lagrange interpolant basis functions,
% evaluated at x.
%
% It returns a 2-dimensional matrix with the values of the Lobatto basis
% interpolants evaluated at x.
%
% If x is a vector of length N it returns a 2d matrix whose rows are the
% values o... |
close all;
%% 读取BAB结果,显示
submap_index = 1;
submap_radon_index = 166;
point_index = 5760;
resolution = 0.02;
path = '/home/yaoshw/Downloads';
%% 是否达到最低分辨率要求
lowres = importdata([path '/BAB/LowResCan_' num2str(submap_index) '_node_' num2str(point_index) '.txt']);
max_score = lowres(lowres(:,2)==max(lowres(:,2)),2)
if ma... |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [pFacs, inds] = primeFactors(n)
% Return row vectors
%
% p_1 p_2 ..., p_k
%
% prime factors of n and corresponding indices
%
% d_1, d_2, ..., d_k
%
% i.e.
%
% n = p_1^d_1 p_2^d_2 .... p_k^d_k
%
if n ~= round(n)
error('prim... |
%% The function performs texture mapping based on delaunay triangualtion.
%
% Prototype:
% mapped_img =
% do_texture_mapping_with_delaunay(probe_mesh_pts, prob_image, tri,verbose)
%
% Inputs:
% probe_mesh_pts ... a Nx2 matrix of coordiantes that define the probe shape
% prob_image ... t... |
function [img_dat, hdr] = AOI_read_vdaq(blkfile, odt)
% Read a *.BLK file acquired with Vdaq into Matlab.
%
% DESCRIPTION
% This function reads in a *.BLK file that was acquired with the Vdaq software
% from Optical Imaging Ltd (http://www.opt-imaging.net/).
%
% Based on the function in the Sunin34H0... |
%param selection
% Emanuel Ravemyr 19/11 -2020
%%setup
clear
rng(1);
N = 100; % number of source particles
%% Parameter selection
L = 1; % box side length
box = [L L L]; % periodic box
opt.box = box;
%Ewald params
M0 = 32; % Set M0=M/L, the restu * 1+ is automatic
opt.M = M0*opt.box;
opt.xi = M0*pi/12;
% charge-ne... |
function [Gridarray] = CreateComplexGrid(n)
%Creates a 2D array of size n x n which can be visualized as a storage of
%complex values which are equally spaced between x =(-2,2) and y =(2i,-2i)
%
% INPUT = n (a positive integer which specifies rows and cols for the
%output 2D array
%
% OUTPUT = n x n 2D array... |
% clear;clc;close all
dates_all_hypervde={'Dec_22_14' 'Feb_03_15' 'Feb_03_15' 'Feb_10_15' 'Feb_10_15' 'Mar_03_15'...
'Mar_06_15' 'Mar_10_15' 'Mar_10_15' 'Mar_10_15' 'Mar_11_15' 'Mar_16_15'...
'Mar_16_15' 'Mar_16_15' 'Mar_16_15' 'Mar_17_15' 'Mar_17_15' 'Mar_18_15'...
'Mar_18_15' 'Mar_23_15' 'Mar_23_15' 'Mar... |
% DM core %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function param = DM3D(param,DMtab)
uicontrol('Parent',DMtab,'String','Stop DM','Units','normalized',...
'Position',[0.1 0.18 0.8 0.1],...
'Callback',@stopReconstruction);
function stopReconstruction(hObj,callbac... |
function freq = datfreq(dat)
% datfreq Frequency of IRIS serial date numbers.
%
% Backend IRIS function.
% No help provided.
% -IRIS Macroeconomic Modeling Toolbox.
% -Copyright (c) 2007-2017 IRIS Solutions Team.
%--------------------------------------------------------------------------
freq = round(100... |
clear;clc;
load databasealpha8.mat;
k=2;
hasilknn = [];
kelaserror = 0;
[n m] = size(database);
Xtrain = database;
Ltrain = [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2];
Ltrain = Ltrain';
Xtest = database;
Ltest = Ltrain... |
close all; clear;
load('CircuitOfAmerica.mat');
load('VehicleDataAudiTTS.mat');
path_ori = preprocessTrack(Track);
%% Extract path information
ds = 5;
path.s = 0:ds:5520;
path.K = path_ori.func_dtheta(path.s);
path.psi = path_ori.func_theta(path.s);
path.cline = path_ori.center(path.s);
path.w_r = path_ori.func_wr(pa... |
function v_out = Rotate_IMUframe_2_Frame(v_in,phi,theta,psi)
%#codegen
s_phi = sin(phi); c_phi = cos(phi);
s_theta = sin(theta); c_theta = cos(theta);
s_psi = sin(psi); c_psi = cos(psi);
IMUframe_2_frame = ...
[ c_psi*c_theta c_psi*s_theta*s_phi-s_psi*c_phi s_psi*s_phi+c_psi*c_phi*s_theta; ...
... |
% created by wykys 2016
function [ prav ] = distribucni_fce( matice, prah )
% funkce vrátí hodnotu distrubuční fukce, vstupem je výstup fukce
% matice_datr a prahová hodnota
prav = 0;
for i = 1:size(matice,1)
if matice(i, 1) <= prah
prav = prav + matice(i,2);
end
end
end
|
# -*- octave -*-
function [fs,x,n]=plot_ts_freqstrength(plotFileName, dataFileName, v0, threshold)
system(["gzip -dc " dataFileName ...
"| awk '!/^#/ {printf(\"%.6f %f %f %f\\n\", substr($2,0,2)+substr($2,4,2)/60+substr($2,7,10)/3600, $3,$5, $7)}' > fs"]);
fs=load("fs");
r = sprintf("%d/%d/0/40", v0-200, ... |
clear all
im_size = 128;
% Square in the middle
square_size = 28;
im_square = zeros(im_size, im_size);
low_ind = (im_size-square_size)/2;
high_ind = (im_size+square_size)/2;
for i = low_ind:high_ind
im_square( low_ind:high_ind, i) = 1;
im_square( i, low_ind:high_ind) = 1;
end
% Load Sheep-Logan image
im_s... |
function generateMsgsMod()
%Create the CAN message with following arguments
%canMessage(<Message ID>,<Enable CAN 2.0B>,Data Length in bits)
msgTx01 = canMessage(01, true, 4);
msgTx500 = canMessage(500, true, 0);
msgTx800 = canMessage(800, true, 6);
msgTx1110 = canMessage(1110, true, 0);
... |
function [inputMovie] = removeStripsFromMovie(inputMovie,varargin)
% Removes vertical or horizontal stripes from movies.
% Biafra Ahanonu
% started: 2019.01.26 [14:17:16]
% inputs
% inputMovie = [x y frames] 3D matrix movie.
% outputs
% inputMovie = [x y frames] 3D matrix movie with stripes removed.
[inputMo... |
%% Limpar tela, console e variáveis
clc;
clear all;
close all;
pkg load control;
%% Declaração sistema e modelo de referência
t = linspace(0,2.5,1000);
u = [zeros(100,1); ones(200,1); zeros(500,1); ones(200,1)];
s = tf('s');
G = (1/(s^2 + 2*s +1))*[(2*s+1) 1; -1 (2*s+1)];
Wm = (10/(s+10))*eye(2);
%% Declaração matrizes... |
function [ Y ] = DFP(f,x0 )
%%----------------------------------------------------------------------------------------------
% Author: Hemanth Manjunatha
% Date: Oct-13-2015
%
% Function : DFP.
%
% Purpose : Implements DFP method algorithm to find the minima.
%
% Parameters : f-> function of interest, x0-... |
dataSet = [0.23, 61.5, 326;
0.21, 59.8, 326;
0.23, 56.9, 327;
0.29, 62.4, 334;
0.31, 63.3, 335];
mu = mean(dataX);
x_minus_mu = dataSet(1, :) - mu;
x_minus_mu_T = x_minus_mu';
cov_dataSet = cov(dataSet);
inv_cov = inv(cov_dataSet);
mahla = sqrt... |
clear all
dur = 1;
fs = 48828.125;
%BPfilt = designfilt('bandpassiir', 'StopbandFrequency1', 190, 'PassbandFrequency1', 200, 'PassbandFrequency2', 1500, 'StopbandFrequency2', 1550, 'StopbandAttenuation1', 30, 'PassbandRipple', 1, 'StopbandAttenuation2', 30, 'SampleRate', fs);
% BPfilt = designfilt('bandpassfir', 'Stopb... |
function [spatialCc, numIC1, numIC2] = raicar_calcSpatialCc (icasig, icasig2)
numIC1 = size (icasig,1);
numIC2 = size (icasig2,1);
comboCc = corrcoef ([icasig', icasig2']); % a combo cc matrix, upper right corner is the cross-correlation of two mixs
spatialCc = comboCc (1:numIC1, numIC1+1:numIC1+numIC2);
... |
function cst = func_EnzymaticDetox_Filtrate2K(xi)
% Modeling toxin enzymatic degradation
% Km = 6;
global texp Texp Km
%% Parameters
dE = 0.1*xi(1); % 0.2, enzyme degradation rate, 1/hr
E0 = xi(2); % initial enzyme concentration, converts 1 ug/ml per hr (50.5 uU/ml)
%% Initial conditions
T0 = mean(Texp(:,... |
%
% read train data or test data from file
%
function [X,y] = readData(X_file,y_file)
% X :matrix of feature vectors,each line is an instance's feature vectors
% y :the class label
X=load(X_file);
y=load(y_file);
end |
function x = emailFeatures(word_indices)
n = 1899;
x = zeros(n, 1);
for i = word_indices
x(i) = 1;
end
% =========================================================================
end
|
%lambda = lambda1/lambda2;
rho2 = zeros(6,1);
gamma = 3;
eps1 = @(psi,lambda) 2*((cos(psi)).^2)./(pi*(lambda + 4*((cos(psi)).^2)));
eps2 = @(lambda) 1/(3*(lambda+1));
Lambda = [1,1/2,1/4,1/8,1/12,1/16,1/20,1/24,1/28,1/32];
for i = 1:10
lambda = Lambda(i);
rho2(i) = integral(@(psi)eps1(psi,lambda),-pi/2,-pi/3)... |
close all, clear all, clc;
rgbim = imread('corner2.gif'); % Read in image
% ÅжÏͼÏñÊÇ·ñΪ»Ò¶ÈͼÏñ
if (size(rgbim,3) ~= 1)
gray_img = rgb2gray(rgbim);
else
gray_img = rgbim;
end
grayim = double(gray_img)/255; % Convert to grayscale
css = []; % Initialize CSS image
limit = 20; % Set sigma limit for non malign... |
% Name: Zheng Wen
% USC ID: 7112807212
% USC Email: zwen1423@usc.edu
% Submission Date 3/3/2020
function img = step_delete(img, delete_if_1)
[m,n] = size(img);
for i=1:m
for j=1:n
if img(i,j) == 0
continue
end
if delete_if_1(i,j) == 1
img(i,j) = 0;
... |
function [keys, values] = extractKeysAndValues(mapping)
%EXTRACTKEYSANDVALUES Extract keys and values from mapping.
if isa(mapping, 'containers.Map')
[keys, values] = extractMap(mapping);
elseif isstruct(mapping)
[keys, values] = extractStruct(mapping);
elseif iscell(mapping)
[keys, values] = extractCell(m... |
load_gallery_path = sprintf('%s\\lfw_man5pt_openset_gallery_%d0k.mat', path, test_iter);
load(load_gallery_path);
gallery = features;
gallery_path = image_path;
load_probe_path = sprintf('%s\\lfw_man5pt_openset_probe_%d0k.mat', path, test_iter);
load(load_probe_path)
probe = features;
probe_path = image_path;
load('l... |
function [ statues ] = checkDir(path)
if (~exist(path))
statues = 0;
mkdir(path);
end
statues = 1;
end
|
%%
% Chapter 5. Rectangular Sum
% DATE: 05/21/2018
% AUTHOR: MINHYUK NAM
%% 1. Plotting Convergence
syms n % declare variable n
a(n) = (n+1)/n;
N = 1:100;
plot(N, a(N), 'x')
% c.f., We cannot conclude that the function converges to 1 by only using the
% plot, RATHER USE order of convergence: abs(a_{n+1})/(abs(a_n))^p... |
function threeshimmerexample(comPort1, comPort2, fileName1, fileName2, captureDuration) %comPort3, fileName1, fileName2, fileName3, captureDuration)
%TWOSHIMMEREXAMPLE - Demonstrate basic features of ShimmerHandleClass
%
% TWOSHIMMEREXAMPLE(COMPORT1, COMPORT2, CAPTUREDURATION) plots the 3
% accelerometer signals fro... |
function [Z, ratios] = tripletCheck(y, triplets)
% TRIPLETCHECK checks if the triplets are satisfied in the maps
%
% [Z, ratios] = tripletCheck(y, triplets)
%
% Function validTriplet checks if the triplets are satisfied in the maps y.
% It returns the binary indicator variables Z and the sat. ratios as output.
%
% inpu... |
function [data, series] = extractTrialState(trial, names, t_span)
data = [];
series = {};
if nargin < 3
t_span = 1:length(trial.interp.t);
end
if ~iscell(names)
names = {names};
end
for n = 1:length(names)
name = names{n};
new_data = [];
if any(strcmp(name, fieldnames(trial.interp.Control)... |
clear all;
height=100;
width=100;
ColMap=[
0, 0, 0;
0,1,1
];
data= load(['/home/xiaoling/SpiralWave/data/Spi7_n6_2Rho0t240p580c10_map.dat']);
data=data(height+1: height+height,:);
figure
imagesc(data);
hold on
plot([40, 40 ,40, 30, 20, 10, 20, 20, 30, 40],[70, 80, 90, 90, 90, 80, 85, 80, 75, 70... |
function [keepAllFeature] = generateFeaturemat(imgPath,fileNames,matchingFunc,featureFunc,heightMatter)
% function [keepAllFeature] = generateFeaturemat(imgPath,fileNames,matchingFunc,featureFunc,heightMatter,featurePath)
% if((exist(featurePath,'dir'))==0)
% mkdir(featurePath);
% end
nImages = (length(fileN... |
%formation of image by cosine signal
clc;
close all;
clear all;
i=1:2560
j=1:2560
x = zeros(2560);
for i=1:2560
for j=1:2560
x(i,j)=cos(pi*(i+j));
end
end
x
figure;
stem(x);
figure;
plot(x);
figure;
imwrite(x,'chess.tif');
a=imread('chess.tif')
imshow('chess.tif');
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.