text stringlengths 8 6.12M |
|---|
% Arduino analog channel for spirometer signal
spirometerAnalogID = 0;
fprintf('Waiting for spirometer command');
% get the initial spriometer value
spirometer_value = analogRead(a,spirometerAnalogID);
% use a while loop to wait for spirometer value to exceeed threshold
while (spirometer_value < 550)
% fprintf a... |
% Copyright (C) 2009-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
% Michele Tavella <michele.tavella@epfl.ch>
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of ... |
A = load('testfile.txt');
angle = A(:,2)*pi/180;
dist = A(:,3);
X = cos(angle).*dist;
Y = sin(angle).*dist;
plot(Y,X,'*') |
function [J grad] = nnCostFunction(nn_params, ...
input_layer_size, ...
hidden_layer_size, ...
num_labels, ...
X, y, lambda)
Theta1 = reshape(nn_params(1:hidden_layer_size * (inpu... |
tilepath = '/home/alex/Desktop/Data/Tiles';
register = 0;
%Get the file location and names
stimList = dir(tilepath);
stimList = stimList(~ismember({stimList.name},{'.','..','config_dir'}));
num_tiles = numel(stimList);
meanimg_xy = cell(num_tiles,1);
unit8_max = double(intmax('uint8'));
%Main loop
parfor tile = 1:num_... |
clear
load('train.mat');
delete('empty/*.jpg');
delete('full/*.jpg');
N = 500;
counter_full = 1551;
counter_empty = 547;
for i = 1:N
source = strcat('numeric/',num2str(i-1,'%05.5i'),'.jpg');
full = strcat('full/',num2str(i-1,'%05.5i'),'.jpg');
empty = strcat('empty/',num2str(i-1,'%05.5i'),'.jpg');
A... |
% Amelia Nathan
% AMATH 482, Winter 2021, Jason Bramburger
% Homework 1
%% Set up, initialization
% Clean workspace
clear all; close all; clc
load subdata.mat % Imports the data as the 262144x49
% (space by time) matrix called subdata 5
L = 10; % spatial domain
n = 64; % arbitrary value; chosen as power of 2 for eff... |
function varargout = fhpkg_cns_type_c(method, varargin)
% Defines the "c" cell type. A "c" cell pools the values of nearby cells (in position or scale) in a previous group.
%
% This is an abstract type; the particular pooling function is undefined (and left to subtypes).
%********************************************... |
cd /Users/Abigail/Documents/Experiment_Data/Experiment_5
participantCodes = {'AW' 'AX' 'AY' 'AZ' 'BA' 'BB' 'BD' 'BE' 'BF' 'AS'}; %
for iParticipant = 1:length(participantCodes)
currParticipantCode = cell2mat(participantCodes(iParticipant));
%load 0 deg gap data and extract the information we need fo... |
function [ ace_out, gasname ] = read_ace_ncdata( filename )
%A function to read the ACE v3.5/6 .nc data and output a structure with
%the information.
% *INPUT*
% filename: STRING - the name of the .nc file that holds the ace
% data
%
% *OUTPUT*
% ace_out: MATLAB STRUCTURE with the fol... |
function BP = bandpass(timecourse, SamplingRate, low_cut, high_cut, filterOrder)
% BP = bandpass(timecourse, SamplingRate, low_cut, high_cut, filterOrder)
if (nargin < 5)
filterOrder = 2;
end
[b, a] = butter(filterOrder, [(low_cut/SamplingRate)*2 (high_cut/SamplingRate)*2]);
BP = filtfilt(b, a, timecourse );
|
function [pah,color_bar] = m_plot_dot(X,Y,C,C_lim,dotsize,cmap,c_label,cborientation)
% m_plot_dot Plots colored dots based on Z value
%-------------------------------------------------------
% University of South Florida, Ocean Circulation Group
% Sage's Codar Processing Toolbox v1.0
%---------------------------... |
% Numerical Optimization - Brute Force Search in 2D
% Created by: Atif Shoukat Ali
% Email : atif@atifali.ca
close all;
clear all;
clc;
%%
% function, range and accuracy pre-defined
f = @(x,y) (x.*y)./(2 + (2.*(x.^4)) + y.^4); % the given function
a = 0; b = 3; % x range
p = 0; q = 4; % y range
w = 0.1; % accuracy of... |
%% =========== Start MR_Autoencoder =============
close all;
%% Prepare Inputs:
Load_Data;
%% set trangnig set and training lable
train_set = training_set';%train_set(1:number_of_input_neurons,1:number_of_training_samples);
%% =========== Create Network Layer's ================================================... |
function [mem_total,mem_used,mem_available]=memory_get();
% memory_get: Get memory inforation on Unix and Windows systems
%
% Call:
% [mem_total,mem_used,mem_available]=memory_get;
%
%
mem_total=[];
mem_used=[];
mem_available=[];
if isunix
[r,w] = unix('free | grep Mem');
ws=split(w);
mem_total=str2num... |
% Admittedly, a near copy of the cost function file provided by Andrew Ng however
% altered to reflect the change in architecture. This file returns the cost and
% the gradients which are needed for the fmincg algorithm to run.
function [J grad] = nnCost(nn_params, input_layer_size, hidden_layer_size, num_labels,... |
function DayNightbargraph3(bin,fileLPG1,fileDPG1,fileLPG2,fileDPG2,fileLPG3,fileDPG3,fileLPG4,fileDPG4,fileLPG5,fileDPG5)
if nargin==11
A=[nanmean(fileLPG1');nanmean(fileDPG1')];
AE=[nansem(fileLPG1');nansem(fileDPG1')];
B=[nanmean(fileLPG2');nanmean(fileDPG2')];
BE=[nansem(fileDPG2');nansem(fileDPG2')];
C=[nanmea... |
% Generates the data for the offspring distriutions.
%
% Code is mainly copy-pasted from "FourStrategiesRun", so refer to this
% script for comments on basic structure.
kk_cases = 2;
nsimu = 100;
t = 100;
offspring_sec = NaN(kk_cases,nsimu);
offspring_tert = cell(kk_cases,1);
for jj = 1:nsimu
clearvars -EXCE... |
function plotsinglechannelmovavg(channelnum,tstart,tend,data)
sampleperiod = 0.0005;
noise=data;
%noise = dlmread('bloutooth_file_transfer.txt','\t');
noise=noise(:,channelnum-10);
numofsamples = size(noise,1);
numofchannels =length(channelnum);
t = sampleperiod:sampleperiod:(numofsamples*sampleperiod);
for i = 1:numo... |
clear;
clc;
%get the data
load("usps_modified.mat");
[X,Y] = getfeatures(data);
%put 400 for each in train dataset, 100 for each in test dataset
[Xtrain,Ytrain, Xtest, Ytest] = orangizeData(X,Y);
%d=1, for Batch gradient; d=2, for stochastic gradient
for d = 1:2
learnRate =50; % learning Rate:... |
clear;
load('twomoons_sk.mat')
gnd = gnd';
n = length(fea);
% data normalization
feastd = std(fea);
feastd(feastd == 0) = 1; % some pixels are 0 in all images
fea = (fea - mean(fea)) ./ feastd;
% number of sets of samples
n_sets = 1000;
% number of samples in each set
n_samples = 20;
sigma = 1.0; % the sigma is impor... |
M = 64;
w = blackman(M);
figure(1);
subplot(3,1,1);
plot(w,'*');
title('Blackman Window');
xlabel('Time (samples)');
ylabel('Amplitude');
zpf = 8;
xw = [w',zeros(1,(zpf-1)*M)];
Xw = fft(xw);
spec = 20*log10(abs(Xw));
spec = spec - max(spec);
nfft = zpf*M... |
function Y = inv_p_transform(transform, Z)
% Inverse procrustes transformation
Y = [inv(transform.b) * (Z' - transform.c) * inv(transform.T)]';
end
|
%% IniMomJet
% Initialises the momentum Field RhoU, RhoV of a jet
function [RhoU,RhoV]=IniMomJet(Rho,Imap2,Jmap2,JJet)
% Parameters
Imidm=Imap2/2; Jmidm=Jmap2/2; Jmidp=Jmidm+1;
Mag = 1.0;
% Momentum in axial direction
RhoU(1:Imap2,1:Jmap2) = 0;
RhoU(1:Imap2,Jmidm-floor(JJet/2)-1:Jmidp+ceil(JJet/2)+1) = Rho*Mag/2;
... |
function ampsout = findamps(ints,allamps)
eps=1e-12;
ints=map2colvec(ints);
allamps=map2colvec(allamps);
temp=amp2int(allamps);
ampsout=zeros(size(ints));
for ind1=1:length(ints)
for ind2=1:length(allamps)
if abs(ints(ind1)-temp(ind2))<=eps;
ampsout(ind1)=allamps(ind2);
bre... |
%Nhom 1
%53
%Pham Ba Tung
%B15DCDT221
I=imread('nen.jpg'); % Doc anh
subplot(1,3,1); %chia cua so ve do th? thanh 3 khong gian va ve dt vao vung 1
imshow(I);
T=im2bw(I, 0.1); % chuyen hinh anh xam sang hinh nh? phan , tach nguong
subplot(1,3,2);
imshow(T); % |
function [data_segments_list, data_events_list] = get_segments(subject_list, var_name, segment_event, event_values, is_value_matching)
num_subs = length(subject_list);
if nargin < 5
is_value_matching = false;
end
if nargin < 4
event_values = [];
end
if num_subs > 1
data_segments_list = cell(num_subs, 1)... |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Salida de un sistema, para una entrada formada %
% por un pulso de banda angosta modulado y un sistema %
% con respuesta en fase cero, lineal y no lineal %
% a partir de una Fase Cero, Lineal y No Lineal %
% ... |
% Running the transient dynamics for the AME, PA and MF frameworks for two different values of the coopertative SIS transmission parameter beta (one below the critical point, one above)
% MAKE SURE THAT LINES 12-17 OF F_rates.m ARE UNCOMMENTED
% Get the degree distribution Pk aswell as Kmin, Kmaz, average degree etc
... |
function [x,y,t] = AMIGO_ParetoFilter(x,y)
% AMIGO_ParetoFilter(x,y) checks if any of the (x,y) points are dominated
% and eliminates those. Also removes points if they are too close to each other
% SYNTAX:
% [xs,ys] = AMIGO_ParetoFilter(x,y) returns the remainig points
% [xs,ys,filtInd] = AMIGO_ParetoFilter(x,y)... |
function [a b c d]=fSplinea(m,x,y)
%teremos 'm' splines cúbicas, uma para cada intervalo, formando um sistema tridiagonal de 'm-1' equacoes para S (derivadas de segunda ordem)
for i=1:m
h(i)=x(i+1)-x(i);
end
% Splines naturais/lineares NAS PONTAS da figura S1=0 e Sm+1=0
%1a. eq. i=2
t(2)=0; r(2)=2*h(1)+2*h(2);... |
function J=ImageDerivatives2D(I,sigma,type)
% Gaussian based image derivatives
%
% J=ImageDerivatives2D(I,sigma,type)
%
% inputs,
% I : The 2D image
% sigma : Gaussian Sigma
% type : 'x', 'y', 'xx', 'xy', 'yy'
%
% outputs,
% J : The image derivative
% Make derivatives kernels
[x,y]=ndgrid(floor(-3*sigma):ceil... |
function [ str ] = isexchangable(A)
%ISEXCHANGABLE 判断A矩阵是否可交换
% 输入矩阵A和自变量t
syms t t1 t2;
A1=subs(A,t,t1);
A2=subs(A,t,t2);
B=A1*A2;
C=A2*A1;
result=isequal(B,C);
if result==1
str='可交换';
else
str='不可交换';
end
|
function p = predict(Theta1, Theta2, X)
%PREDICT Predict the label of an input given a trained neural network
% p = PREDICT(Theta1, Theta2, X) outputs the predicted label of X given the
% trained weights of a neural network (Theta1, Theta2)
% Useful values
m = size(X, 1);
num_labels = size(Theta2, 1);
% You need ... |
function [hist,fhandle,posMean,negMean,totMean]=histogram(data, diffTime, binSize, maxBin, minBin, plotFlag)
% function [hist, fhandle,posMean,negMean,totMean]=histogram(data, diffTime, binSize, max, min, plotFlag)
% given a vector of data and times/weights for the data, binSize, max value
% and min value, a structure ... |
function result = number_of_lines(filename)
result = 0;
fid = fopen(filename);
while (1)
next = fgetl(fid);
if (next(1) == -1)
break;
end
result = result + 1;
end
fclose(fid);
|
% $Header: svn://.../trunk/AMIGO2R2016/Postprocessor/Post_Plot/AMIGO_plot_ellipse.m 770 2013-08-06 09:41:45Z attila $
function AMIGO_plot_ellipse(major_axis,minor_axis,mux0,muy0,phi,lineformat)
% AMIGO_draw_ellipse: Draws ellipses for the robust identifiability analysis
%
%*********************************************... |
close all;
clear;
data_file = fopen("data2.txt", 'w');
Fs=48e3;
dt = 1/Fs;
t=(0:dt:(2.135e-2)-dt);
amp = 1;
s1 = amp*cos(2*pi*1200*t);
s2 = amp*sin(2*pi*3600*t);
s3 = amp*sin(2*pi*7600*t);
s4 = amp*sin(2*pi*14000*t);
s5 = amp*sin(2*pi*17000*t);
y = s1+s2+s3+s4+s5;
y=y/5;
digital_y = round(((2^23)-... |
function imColourBar(colours)
clrsize = size(colours);
k = clrsize(1);
cmap = colours/255.0;
colormap(cmap);
labels = cell(k,1);
for i=1:k
labels(i) = cellstr(['Colour ', int2str(floor(i))]);
end
colorbar('Ticks', linspace(1/(2*k),1-1/(2*k),k),...
'TickLabels',labels); |
classdef ConfigStage
%UNTITLED3 Summary of this class goes here
% Detailed explanation goes here
properties
id string
name string
operations ConfigOperation
end
methods
function obj = ConfigStage(name)
%UNTITLED3 Construct an instan... |
clf;close all;clear all
N = 20;
sig = randi([0,1],1,N);
sig((sig==0)) = -1;
symbol_rate = 1e6;
% carrier frequency is 1/4 DMA frequency
fc = 8e6;
% Both IF frequency and (carrier frequency-IF frequency) is the 1/4 of ADC frequency
fIF = 4e6;
freq_DAC = 16e6;
freq_DMA = 32e6;
f_DAC = 16;
f_DMA = 2;
group_delay = 2;
s... |
Input_States = de2bi(0:2^(2^Num_var)-1,'left-msb')';
ABC = States(1:8,:);
BCA = States([1,3,5,7,2,4,6,8],:);
ACB = States([1,3,2,4,5,7,6,8],:);
Combinations = [ABC BCA ACB];
Others = [];
for i=1:size(Input_States,2)
indx = find(sum(abs(Combinations-repmat(Input_States(:,i),1,size(Combinations,2))))==0);
i... |
function [X,Pressure,Density,Vx,time]=read_hdf1D(filename,ShouldPlot,WhatToPlot,LogScale)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Matlab script to read RICH binary files in float/double format
%
% Inputs : filename - The location of the binary file
% ShouldPlot ... |
function m_Euler_mj(f,x,y,h,lim)
f = str2func(f);
xn(1)= x;
yn(1)=y;
i=1;
while(x<=lim)
y=y+h*(((2*x*y)+2*(x+h)*(y+h*2*x*y))/2);
fprintf('Y%d=%.4f \n\n', i,y);
x=x+h;
i=i+1;
xn(i)=x;
yn(i)=y;
end
xn
yn
end |
% Data from Suzuki et al. 2006
x = [0, 0.01, 0.02, 0.04, 0.1, 0.5, 1]; % amount of ionizing radiation (X-Rays) in Gy
y = [0.1, 0.3, 0.9, 1.5, 4, 11, 14]; % number of ATM focis
scatter(x,y)
set(gca,'xscale','log','yscale','log');
hold on;
fplot(@(x) 0.0429 + 45.4628.*x - 62.0548.*x.^2 + 30.6344.*x.^3) % approximation ... |
function [ output_args ] = processFunctionID_2( functionIDs, functionNames, dataStream )
%ACK
functionID_index = 2;
functionID = functionIDs( functionID_index, : );
tagLength = getTagLength( functionID )
functionNames{ functionID_index }
Command = functionID(1:tagLength)
index = tagLength... |
% The main function for feature computing.
% The feature functions are all called with the same parameter.
clc;close all;clear all;
features{1}=@myAdd;
features{2}=@mySub;
a=10;
b=5;
for i= 1:2
disp(features{i}(a,b));
end
|
r1 = 20.57; % Stator resistance
x1 = 24; % Stator Inductive reaction
r2 = 12.75; %Rotor resistance
x2 = 20.58;% Rotor Inductive reaction
xm = 117.21;% Vertical Inductive Reaction
rc=4921.8;% Core loss resistance
v_phase_1=138; % Phase voltage
v_phase_2=415/sqrt(3);
n_sync = 1500;% synchronous speed (r/min)
... |
function Controller(block)
setup(block);
function setup(block)
block.NumInputPorts = 3; % pos, Fen, Fet
block.NumOutputPorts = 3; % Fd, E
block.SetPreCompInpPortInfoToDynamic;
block.SetPreCompOutPortInfoToDynamic;
block.InputPort(1).DatatypeID = 0; % double
block.InputPort(1).Comp... |
close all;
clearvars;
%% setup rate constants
e = 1.602e-19; % fundamental charge in coulombs
%% set up simulation
ints = [0.1,1,10,100,1000];
for I=ints
[ks, epsilon, mu_h, mu_e, d] = aj_constants_fun(I);
dydt = curr_model(I, ks, epsilon, mu_h, mu_e, d);
tspan = [0,40e-6];
y0 = [0;0;0];
[ts, ... |
% Generates test fixtures for whole cell simulation.
%
% Author: Jonathan Karr, jkarr@stanford.edu
% Author: Jared Jacobs, jmjacobs@stanford.edu
% Affilitation: Covert Lab, Department of Bioengineering, Stanford University
% Last updated: 5/31/2011
function generateTestFixtures()
import edu.stanford.covert.cell.... |
close all; clear; clc;
%% find envelope for X~HN(1) (exp(1))
x = 0:.01:10;
hnDis = makedist('Normal');
hnPdf = 2 * pdf(hnDis, x);
plot(x, hnPdf);
hold on;
plot(x, 1.5 * exp(-x), 'r'); % the envelope function is simply 1.5*exp(1)
xlabel('X1','FontSize',15);
ylabel('pdf and its envelope','FontSize',15);
%% RNG X1
N = ... |
%{
bs.BrainState (computed) # brain state from patch
-> reso.Sync
-----
-> patch.Ephys
band_low : decimal(5,2) # Hz
band_high : decimal(5,2) # Hz
brain_state_trace : longblob # trace classifying brain states
%}
classd... |
function [ J, p ] = current1D_noRecomb(x, V, pl, pr )
%This gives the current density and charge distribution for a 1D voltage
%distribuion
%assuming boundary condition for leftmost side (i.e. set left to 0 V)
%Inputs
% V: array of voltages
% pl: boundary condition for hole concentration at the left contact
% pr: boun... |
function [encodedSignal,time] = pnrz(inputBinaryData,Ts,N)
%PNRZ Summary of this function goes here
% A function that encodes a binary bit using Polar NRZ
Tb=N*Ts;
Ws=2*pi*N/Tb;
%Sampling time
t=2*pi/Ws;
%% T will be equal to one here as N=40, Ts=1, Tb=40
time=0:t:length(inputBinaryData)*Tb;
encodedSignal = zeros(1,... |
%%%%%%%%%%%%%%%%%%% Time-Specific Effect Comparison Sim %%%%%%%%%%%%%%%%%%%
% Time-Specific Effect %
% x(v) ~ GP(0, S) S~AR(1) estimated covariance from data %
% Fitting Malfait & Ramsay (2003) FEB model, FDBoost, and Refund %
% N = 50/200, T ... |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%USING A ZERO-INVESTMENT PORTFOLIO TO REDUCE ESTIMATION
%RISK IN MEAN-VARIANCE PORTFOLIO OPTIMIZATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DRAFT: LUIS CARLOS CHAVEZ-BEDOYA
% DATE: JULY 24TH, 2017
% CODE: JAN 2018
% EDITED: FRANCISCO ROS... |
%% Collect features to be extracted into matrices
global gamma_max delta_aa kurtosis C_20 C_40 mod_type symPerFrame delta_a delta_ap delta_dp
gamma_max = [];
delta_aa = [];
delta_a = [];
delta_ap = [];
delta_dp = [];
kurtosis = [];
C_20 = [];
C_40 = [];
mod_type = {};
%% Define number of symbols per frame
%symPerFra... |
clear
addpath('./core');
%Parameters of the model
%Constants
Qmax=340;
alpha=45;
beta=186;
gamma=116;
range=0.086;
sigma_rho=0.0038;
theta=0.01292;
t0=0.085;
%AAS Model
tau_v=10.0;
tau_m=10.0;
nu_vc=-2.9e-3;
nu_vh=1e6;
nu_vm=-2.1e-3;
nu_mv=-1.8e-3;
xi=45*3600;
mu=4.4e-9;
c0=4.5;
Cphase=2*pi/3;
Ach=1.3e-3;
AASconnectio... |
%return probability vector for nT trials given the sequence of stimuli and
%matrices (parameters specified in info)
function [estTot,estCurr] = getProbEst_Baseline(data, info)
stimT = data(1:info.nT,info.colStim); %stimulus sequence
matT = data(1:info.nT,info.colMat); %sequence of generativ tran... |
function test_data = Get_Data(test_data, i, Stimulus_freq, Beepfrequency)
test_data(i,5) = Stimulus_freq;
test_data(i,6) = Beepfrequency;
end |
%% Circle generation
sz=400;
rad=100;
clear RGB
RGB(1:sz,1:sz,1:3)=255;
[x y]= find(RGB==255);
xc=ceil((sz+1)/2);
yc=ceil((sz+1)/2);
r=rad.^2;
d=find(((x-xc).^2+(y-yc).^2) <= r);
for i=1:size(d,1)
RGB(x(d(i)),y(d(i)),:)=0;
end
B=rgb2gray(RGB);
ED=edge(B);
SE=strel('disk',1);
cir=~imdilate(ED,SE);
... |
clear
clc
format long
%Obter I=integral de Tchebychev de f(x)=ln(1.+x); com erro maximo O(1e-6)
a=-1
b=+1
Ie=-pi*log(2) %integral_(-1)^(+1) (log(1+x))/sqrt(1-x^2) dx = -π log(2)≈-2.17759
m=1e4 %com m=1e6 Erro GTm~2.1775475e-06
GTm =FGTm(m)
ErroexatoGTm=abs(GTm-Ie)
|
function [msh] = fs_inflated2defaultcortex(freesurferSubjectDir,outputName)
%function [msh] = emse_wfr2defaultcortex(wfrFilename,outputName)
%
%A non elegant solution to create a mesh file that works with mrCurrent
%
%It uses the mrMesh format, but doesn't set anything that mrMesh might need
%It just puts things ... |
% Add folders to path.
addpath(pwd);
cd manopt;
addpath(genpath(pwd));
cd ..;
cd utils;
addpath(genpath(pwd));
cd ..;
cd lienet;
addpath(genpath(pwd));
cd ..;
|
function [Tca_diff_pdf,Tca_diff_cdf] = find_pdf_cdf(Tca_diff,x)
Tca_diff((isnan(Tca_diff)))=[];
Tca_diff_pdf = hist(Tca_diff,x);
Tca_diff_pdf = Tca_diff_pdf/length(Tca_diff);
Tca_diff_cdf = cumsum(Tca_diff_pdf)./sum(Tca_diff_pdf); |
function Done(dac)
dac.VPrintf('done!\n');
end
|
classdef (Abstract = true) WvfrmSequence < QHandle
% bass class for all waveform sequence classes
% awg, awgchnl etc are the same as the first waveform of the waveform
% sequence.
% Copyright 2015 Yulin Wu, Institute of Physics, Chinese Academy of Sciences
% mail4ywu@gmail.com/mail4ywu@icloud.com
prop... |
function [ z ] = PCA( X )
% ANI DEVER s225055
% This function computes the Principal Component Analysis
% takes a matrix as an input(X)
% returns the Z matrix which is Z = X*U
% U and the matrix of eigenvectors of R(the covariance matrix of input matrix)
% and X as input matrix(var1)
% returns the Z matrix
N = lengt... |
%Practice 8.1
%Creating two different cell arrays:
cellA={1:5,'Random input', 12; 5.43,"Random string", 9}
cellB={13,20;16,'March'};
%Creating expression
test1=cellA{randi(size(cellA,1)),randi(size(cellA,2))};
clear all
%Practice 8.2
%Creating structure
onepart=struct('part_no',123,'quantity',4,'costper',33.95);
... |
clear,clc,close all;
[X,Y] = meshgrid(-10:.05:10);
% R = sqrt(X.^2 + Y.^2) + eps;
% Z = sin(R)./R;
Z = sinc(X).*sinc(Y);
figure, mesh(X,Y,Z), axis tight;
out = imlin2( Z, 0, 255);
figure, im_Z = image(out), colormap(gray), axis tight; |
function [Iref, Cp, Cd] = controller(q0,q1,dq0,dq1,param)
% [Iref, Cp, Cd] = controller(q0,q1,qd0,dq1,param)
%
% This controller attempts to hold the foot level while the pendulum
% rotates around it.
%
% Returns motor current commands
% Relative joint angle:
% x = q0 - q1;
% v = dq0 - dq1;
% What is the desired rela... |
function [result] = predictRating(bicluster, user_data, item_ix)
%PREDICTRATING Predict user's rating for item based on bicluster data
%% compute the correlation for each pair of users
[~, bicorr] = biclusterCorr(bicluster, user_data);
%% calculate the user's average rating
ix = find(user_data > 0);
ix = ix(ix ~= ite... |
function [Laws] = Feature_Laws(image,window)
%% Function: LawsTexture(image)
% http://sci.tech-archive.net/Archive/sci.image.processing/2007-05/msg00195.html
L5=[1 , 4 , 6 , 4 , 1]; %level (Intensitaet)
E5=[-1, -2, 0 , 2 , 1]; %edge (Kanten)
S5=[-1, 0, 2 , 0 ,-1]; %spot
R5=[1 , -4, 6 ,-4 , 1]; %ripple (Rauhheit)... |
function nrand=gsrandauto(T,ro)
% gets T random numbers with autocorrelation ro
startrand=rand(1,T)-.5; nrand=startrand;
au=autocorr(startrand);
convbound=.005; ccg=10;
convlen=round(T./2);
nrand=conv(startrand,ones(1,convlen)./convlen);
nrand=nrand(round(convlen./2):round(convlen./2)+T-1);
au=autocorr(nran... |
function [p] = VanillaOptionPayoff(S)
%% 西部聚新1号
% 期限 268天
% 到期回报:
% case ST >= 150% * S0:
% 回报利率为 20%
% case 110% * S0 < ST < 150% * S0
% 回报利率为 [(ST/S0 - 1) - 10%] * 0.5
% case ST <= 110% * S0:
% 回报为0
%% 归一化
% S0 = 1
% ST <= 1.1: p = 0
% 1.1 < ST < 1.5: p = 2.5 * (ST - 1.1);
% ST >= 1.5 p = 1;
%% implementation:
... |
clear; close all; clc;
%% Definicao dos valores de treino e normalização dos mesmos
rooms = randi([1 5],1,500)/5;
area = randi([100 1000],1, 500)/1000;
rooms = sort(rooms);
area = sort(area);
price = randi([50, 100],1, 500)/100;
price = sort(price);
%% Definição do learning rate e dos valores iniciais para os coefici... |
function[x,y] = getCCV(img, i, j, VISITED)
% Function to find the patches in the image for the given pixel at img(i,
% j)
% Finding the dimensions of the image
[s0, s1] = size(img);
% Checking if indices are out of bounds
if i<1 || i>s0 || j<1 || j>s1
x = 0;
y = VISITED;
return
end
% Checking if the curr... |
function draw_ellipse( ax,xc,yc,r1,r2,alpha,ltype)
%UNTITLED4 Summary of this function goes here
% Detailed explanation goes here
th = linspace(0,2*pi,50);
x = cos(th)*r1;
y = sin(th)*r2;
plot(ax,xc+x*cos(alpha)-y*sin(alpha),yc+y*cos(alpha)+x*sin(alpha),strcat(ltype,':'));
end
|
function [ x, lambda ] = PCDirecto( Q,A,c,b )
% Juan P Aguilera 136078
% Luis M Román 117077
% Madeleine León 125154
%------------------------------------------
% Resolver el problema cuadrático
% Min (1/2)* x'*Q*x + c' * x
% s. a. A*x = b
%
% donde Q es nxn simétrica positiva definida
% A es mxn y ra... |
function WriteSnipFile(filename,header,snips,times)
% WriteSnipFile: writes a set of snippets to disk in standard format
% WriteSnipFile(header,snips,times)
% snips and times are cell arrays, where each element of the cell
% array is the data for a given channel.
% Exception: if snips & times are matrices, one channel ... |
function DM=GridDM(InGrid, OutGrid, pbc)
% Calculates the distance between all pairs of points from one grid to
% another.
% Grid is a vector of [ no rows, no columns, grid step size]
NoIn=InGrid(1)*InGrid(2);
NoOut=OutGrid(2)*OutGrid(2);
DM=zeros(NoIn,NoOut);
for i=0:NoIn-1
% Convert 1D index to 2D spat coords
... |
var = NFFT;
var(var == 1024) = 1;
var(COMPONENTS == 10) = 2;
var(COMPONENTS == 15) = 3;
var(COMPONENTS == 20) = 4;
grid on
figure
scatter3(ALGORITHMS, SCENARIOS, var, TPS * 8, ALGORITHMS)
set(gca, 'XTick', [0:1:2])
set(gca, 'XLim', [-0.5, 2.5])
set(gca, 'YTick', [1:1:5])
set(gca, 'YLim', [-0.25, 5.25])
se... |
function [Flag, DataFormat]=GetImageHeader(HeaderFile)
Flag=1;
DataFormat=[];
try
HeaderInfo=ReadPinnTextFile(HeaderFile);
catch
Flag=0;
disp('no header file.')
return;
end
TempIndex=strmatch('x_dim', HeaderInfo);
if ~isempty(TempIndex)
TempStr=HeaderInfo{TempIndex(1)};
e... |
%2016-05-12 OFDM transmitter
%2016-06-06 improved notations
%2016-06-07 realised OFDM receiver, added BER calculation
%2016-06-08 added white noise. Added jitter: algorithm is very sensitive to
%jitter
%2016-06-16 added OFDM signal BW = Sub-carrier BW*Nsc2_real, Number of real subcarriers Nsc2_real
%2016-10-15 sucessfu... |
% Name: Zheng Wen
% USC ID: 7112807212
% USC Email: zwen1423@usc.edu
% Submission Date 3/3/2020
function res = matFlip(img, axis)
[m,n] = size(img);
res = zeros(m,n);
if axis == 1
for i=1:m
for j=1:n
res(i,j) = img(m - i + 1, j);
end
end
else
for i=1:m
fo... |
function b=CFP2bandDecomOdd2(a,tanTheta)
%To reconstruct, use CFP2bandReconSub2.m.
sz=size(a);
tanTheta2=tanTheta*tanTheta; scl2=1/(1+tanTheta2);
b=a;
b(1,:)=a(1,:)-a(2,:)*tanTheta; b(2,:)=a(1,:)*tanTheta+a(2,:);
a=b;
%------------------------------------------------------------------------------
b(4:4:sz(1)-5,:... |
function [ var ] = obliczenia(h0, tau)
% funkcja wyliczajaca potrzebne dane takie jak h, t, cn itd.
dtau = diff(tau);
n = ceil(dtau./h0);
h = dtau./n;
h2 = h/2;
h3 = h/3;
h6 = h/6;
cn = cumsum([1 n]);
iter = cn(end);
ldtau = length(dtau);
tf = tau(end);
var = struct('h', h, 'h2', h2, 'h3', h3, 'h6', h6, 'cn', cn, 'it... |
function [EY_x, xnodes, xcount] = EYx( x, y, plotflag, xnodes )
% EYx 条件期望 E(Y|X = x)
% 尊重数学习惯,函数名首字母大写,随机变量Y大写,函数变量x小写
% inputs:
% x :X,vector, x,y 须同长度
% y :Y,vector
% xnodes :x的划分点,默认均分20类,左开右闭
% plotflag : ==1则画图, ==0则不画(默认)
% output:
% EY_x :给定x,Y的期望 (是x的函数)
% xnodes :同in... |
% solve the following problem
% min_{q,x} 1/2*||Y*q - x||_2^2 + lambda * ||x||_1, s.t. ||q||_2 = 1
% by alternating minimization method (ADM).
%
% Y: input data
% q_init: initialization for q, lambda
% lambda: penalty parameter
% MaxIter: max iteration
% tol: tolerance for convergence
% q: output result
%%%%%%%%%%%... |
function reply = hasterminated(W)
% Get the terminate signal from figure's appdata
if ishandle(W.figure)
reply = getappdata(W.figure,'terminate');
end |
%% -------------------- Setup -------------------- %%
clear; clc; clf; hold on; axis equal; syms x y; rosshutdown()
% Initialize variables
neato_pos = [0,0];
neato_dir = 0;
bucket_pos = [2.8194,1.397];
bucket_rad = 0.200/2; % m
turn_time = 1;
error_circ = 0.03;
d = 0.265; % Neato Wheelbase
counter = 0; % Tracks steps... |
function [dtheta,vspeed,vacc]=CalculateAngualMotionPerFrame(X,Y,Angle,TrackingInterval)
% trying
dtheta=CalcAngleChangeOfTrajectory(X,Y);
dtheta=dtheta'*pi/180;
dtheta=[0;dtheta];
dx=diff(X);dy=diff(Y);
vspeed=abs(sqrt(dx.^2+dy.^2)/(TrackingInterval));
vacc=diff(vspeed);
vacc=[vacc(1),vacc'];
% %%% old... |
function ModelBWCompare(subset)
%-- Author:Wang, Peng. Fudan University
%-- Date:2019/11/30
%-- Fuction:show the piture of segmentation result from diffirent model
%% loading and initializating image
load('C:/Github/医学成像技术/project2/Tumor-Segmentation-of-Ultrasound-Breast-Images/Input.mat')
%% imshow
original_image = ... |
clear all;
close all;
clc;
addpath('../tree_matlab/');
addpath('../export_fig/');
%This file compiles the results of all client positions, orientations and
% transmit beamwidths into one file with projected 802.11ad RX power
% measure obtained by firstly the normalized rms rx power then using the
% highest power mea... |
function [final_classifier,ROC_outer]=B2_nested_CV(CCTAtable,modelname,redundancy,comment)
% CCTA data analysis
% Kevin M. Johnson, M.D. Yale University, March 2019
% This is an "outer" crossvalidation routine meant to
% measure the accuracy of the best classifiers.
% For each fold, it calls a "classifier creation ... |
% th=0.5;
% detect_perf5
% ppi=50:50:2500;
% for roci=31:numel(ppi)
%
% ppcount=ppi(roci);
% oneclEp
% mppTP(roci)=mean(ppTP);
% mppFP(roci)=mean(ppFP);
% mnTP(roci)=mean(nTP);
% mnFP(roci)=mean(nFP);
%
% end
pi=0.5:0.1:.9;
for roci=1:numel(pi)
th=pi(roci);
detect_perf5
mpTP2... |
clear all;clc;close all;
gamma_th=2;%0dBm
sigma_G=0.8;%lognormal的sigma参数
PT=10:35;%接收功率(dB)
Pt=10.^(PT/10);%接收功率(W)
U_G=log(Pt.^0.5)-sigma_G^2;
P_EGC_Upper=[];
P_EGC_Lower=[];
sim_EGC=[];
arbtriary_upper_bound=[];
arbtriary_lower_bound=[];
for p=[0.1,0.8]
a=(1-sqrt(1-p^2))/p
U_X=U_G/(a+1);
sigma_X=sqrt(sigma_G^2/(a^... |
function x = matinv(A)
x = inv(A);
end
|
function w = QE(v1, v2, v3, v,n)
% The subroutine is to implement the Quadratic Extrapolation for
% accelerating vector iterations. Then it will be used to accelerate the
% Power iteration;
% Written by Dr. Guojian Yin (HKUST)
% and modified by Dr. Xian-Ming Gu (SWUFE)
% Reference:
% S.D. Kamvar, T.H. Haveliw... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.