text stringlengths 8 6.12M |
|---|
data = load('errorsamples10000.txt');
[m,n] = size(data);
length = m/5;
%perform innovation bound test.
% get the list of error and their correlations.
error_stack = zeros(length, 4);
cov_stack = zeros(length*4, 4);
j = 1;
k = 1;
for i = 1:5:m
error_stack(j,:) = data(i,:);
cov_stack(k:k+3,1:4) = data(i+1:i+4,1... |
% Write and test a script that reads a positive integer N and calculates the sum S=2+4+6+8+...+(2N).
% Lecture4_FlowControl #3
N = input('N');
S=0;
for i=1:N
S=S+2*i;
end
S
|
clc
close all
clear all
rng(2)
% % filename = 'acoustic.wav';
% % filename = 'harpsi-cs.wav';
% % filename = 'trumpet.wav';
% % filename = 'jazztrio.wav';
% % filename = 'marimba.wav';
% filename = 'noise.wav';
%
% [x, fs] = audioread(filename);
% % [x, fs] = wavread(filename);
% x = mean(x,2);
% lenX = length(x);
... |
function [x,density] = modynamicsHS(L,n,N,D,dt,t_final)
% modynamicsHS performs molecular dynamics of a 1D model of hard
% spheres under an external potential of x^2
%
%
% Input arguments
% L Length of the box
% n Number of nodes
% N Number of hard spheres
% ... |
function display(k)
% kronMatrix display(k)
%
% prints the elements of k.a and k.b
%
disp (sprintf ('a ='));
disp(k.a);
disp (sprintf ('b ='));
disp(k.b);
|
%% ------------------------------------------------------------------------
% Compute a given number of iterations of Newton's method
function [y] = newtonIterationBlock(guess, x, num_iterations, W, F, Fm)
y = newtonIteration(guess, x, W, F, Fm);
for i = 2:num_iterations
y = newtonIteration(y, x, W, F, ... |
%% Full-Force Method with Izhikevich Network
clear all
close all
clc
warning('off');
x0 = load('CzChannel80Epochs.mat');
x = x0.dataset{1,1}(:,:,1);
data = double(x);
Fs = 128;
% Uncomment to bandlimit EEG to certain frequency range
%data = bandpass(double(data1),[30 100],Fs);
data = interp(data(1:end),50); % in... |
load('Ex9Part2-TrainingData.mat')
%add 1 at the end of the feature vector
X = [Xtrain, ones(size(Xtrain,1),1)];
%apply least squares with a linear function -> <w,x> + b
w = LeastSquares(X,Ytrain);
%compute the loss
trainloss = norm(Ytrain - X*w,2)^2/1794;
save saveLossSecondExtrainloss trainloss
|
function CALCalibration_prs(obj, evt)
hndl = get(gcf, 'UserData');
hndl = get(hndl.mainFig, 'Userdata');
chndl = get(hndl.calibrationFig, 'Userdata');
set(obj, 'Enable', 'off');
hndl.tdt.RP2.Halt();
rcxf = fullfile(hndl.filepath.tdtPath, 'amfrRZ6CAL.rcx');
hndl.tdt.RP2.ClearCOF;
hndl.tdt.RP2.LoadCOF(r... |
clear all
clc
%% Vykreslení konkrétního signálu jednotlivých svodů (před aplikací shlukovací analýzy)
% Mějte prosím před spuštěním tohoto skriptu ve složce nahrané všechny signály
% od MO1_001_03.mat po MO1_125_03.mat i od MO1_001_12.mat po MO1_125_12.mat
jednotky = 1; %První si musím načíst matici, ve kt... |
function A = sred(r,n)
sum=0;
for i=1:n
sum=sum+r(i);
end
A=sum/n;
|
classdef (InferiorClasses = {?matlab.graphics.axis.Axes}) muellerData
properties
Label % string
Value % 4,4,M,N,... array of Mueller matrix values
ErValue % 4,4,M,N,... array of Mueller matrix error values
Size % size of Value
Dims % cell array of length n... |
function [distance,cGaussRough1,cGaussRough2] = Wang_perceptual_distance(scn1, scn2)
%% This code has been copied from another script
%
% It has been modified for compatibility with the mesh comparison tools
% (https://github.com/psapirstein/mesh-comparing) accompanying:
% "A high-precision photogrammetric recordi... |
function Loh = getLoh(Input)
%UNTITLED9 Summary of this function goes here
% Detailed explanation goes here
HEADER = Input.HEADER;
fields = fieldnames(HEADER);
size = numel(fields);
Loh = 0;
for i=1:size
field = fields{i};
dataType = class(HEADER.(field));
type = char(dataType);
if strcmp(type,'uint32... |
size = 10000;
%error_rate = 0.1;
repeat = 5;
time = 10;
error_rate = 1:20;
for n = 1:20
error_rate(1,n) = error_rate(1,n)/100;
end
%rate1 = zeros(time,repeat+1);
%rate2 = zeros(time,repeat+1);
rate1 = zeros(length(error_rate),repeat+1,time);
rate2 = zeros(length(error_rate),repeat+1,time);
keyl1 = zeros(length(err... |
%{设该系统的状态方程和观测方程为:
x(k) = A · x(k-1) + B · u(k) + w(k)
z(k) = H · x(k) + y(k)
x(k) —— k时刻系统的状态
u(k) —— 控制量
w(k) —— 符合高斯分布的过程噪声,其协方差在下文中为Q
z(k) —— k时刻系统的观测值
y(k) —— 符合高斯分布的测量噪声,其协方差在下文中为R
A、B、H —— 系统参数,多输入多输出时为矩阵,单输入单输出时就是几个常数
注意在后面滤波器的方程中我们将不会再直接面对两个噪声w(k)和y(k),而是用到他们的协方差Q和R。至此,A、B、H、Q、R这几个参数都由被观测的系统本身和测量过程中的噪... |
fname=fullfile(pwd,'odb','J-Indenter_Quarter_homo.dat')
%positions (corner nodes)
positions=[2.781500,2.682161,2.582822,2.483482,2.384143,2.284804,2.185465,2.086125,1.986786,1.887447,1.788107,1.688768,1.589429,1.490089,1.390750,1.291411,1.192071,1.092732,0.993393,0.894054,0.794714,0.695375,0.596036,0.496696,0.397357,... |
function fig = ghalc(varargin);
% ghalc(...)
% Counts
ffig = ne_group(varargin,'Counts','phalca','phalcb','phalcc','phalcd');
if nargout > 0 fig = ffig; end
|
function obs_training = get_fraction_training(obs_full, obs_testing, frac)
% GET_FRACTION_TRAINING - returns a random set of training observations
% given the full observation set and smaller subset
% of testing observations.
%
% Note: Must use 'slice-type' observations
%... |
A_M=single(A_M);
A_l_max_x=single(A_l_max_x);
A_z_max=single(A_z_max);
Alfa=single(Alfa);
Alpha_unique=single(Alpha_unique);
Alpha_unique_rad=single(Alpha_unique_rad);
Alt_0=single(Alt_0);
B_span=single(B_span);
Beta=single(Beta);
Beta_unique=single(Beta_unique);
Beta_unique_rad=single(Beta_unique_rad);
CG=s... |
function ts1_ts2_spread( ts1, ts2 )
%TS1_TS2_SPREAD 两时间序列,ts1, ts2, 画在左轴;右轴画两者的差
% 有一定通用性,故不放在private中
% @luhuaibao
% 2014.6.3
n1 = length(ts1);
n2 = length(ts2);
if n1~=n2
error('两序列长度不等!');
end ;
x = (1:n1)';
y1 = ts1;
y2 = ts2 ;
y3 = y1-y2 ;
setplot.plottype = [{'plot'},{'bar'}];
setplot.legend = [... |
%PLOTINDIVIDUALLEG Plots the kinematic skeleton of an individual Sherpa_TT
%leg.
%
%Inputs:
%-uG: The 1x3 vector that describes the displacement between the Body and
%Ground coordiante frames, relative to the ground coordiante frame.
%-q: The 1x4 vector containing the joint state of the leg.
%-legNum: The leg number id... |
% clear workspace
clear;
% action
M = 100;
L = 1000;
fs = 1;
y = randn(L, M);
r = 10;
h = (1/r) * ones(1, r);
yf = filter(h,1,y);
fyf = fft(yf);
fyf_mag = 10 * log10(abs(fyf));
fyf_mean_mag = mean(fyf_mag, 2);
% plot
figure(8); clf;
plot(FftShiftedFreqs(L, fs), fftshift(fyf_mean_mag));
|
function trainingDaysAccuracy_houseE()
% Percolator
houseE__day_1_2__day_0_1_3_tp = [694.0];
houseE__day_1_2__day_0_1_3_tn = [11126.0];
houseE__day_1_2__day_0_1_3_fp = [228.0];
houseE__day_1_2__day_0_1_3_fn = [132.0];
houseE__day_1_6__day_0_1_3_tp = [706.0];
houseE__day_1_6__day_0_1_3_tn = [11147.0];
houseE__day_1_6_... |
clear all
year = '2011';
Year = eval(year);
iii = 0;
for j = 1:12
if j == 1, border = load(['c://HY-data//BOY//documents//sosa_in/year/',year,'/data_input//M01//border.txt']);
elseif j == 2, border = load(['c://HY-data//BOY//documents//sosa_in/year/',year,'/data_input//M02//border.txt']);
... |
clear
close all
clc
dataset = 'Art';
%dataset = 'Aloe';
%dataset = 'Reindeer';
%dataset = 'Moebius';
%dataset = 'Dolls';
%dataset = 'Teddy';
%dataset = 'Cones';
I1 = single(imread(['datasets\',dataset,'\view1.png']));
D1 = single(imread(['datasets\',dataset,'\disp1_noholes.png']));
[h, w] = size(D1);
mindisp... |
%2.točka
B = [0 0; 2 6; 3 0; 5 4; 7 1; 5 5; 10 6];
B3 = bezierelv (B ,3);
B10 = bezierelv (B ,10) ;
B30 = bezierelv (B ,30) ;
t = 0:0.01:1;
plotbezier(B30,t);
|
#!/bin/octave
## Evan Widloski - 2016-07-14
## DFT Testing - practicing and understanding inverse DFT
duration = 1;
sample_freq = 25;
N = duration*sample_freq;
n = 0:N-1;
x_time = sin(2*pi*1*n/N) + cos(2*pi*5*n/N);
## x = [0 -12.5i 0 0 0 12.5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12.5 0 0 0 12.5i];
x = fft(x_time);
## show ... |
function out=flyVacCorConv(data)
maxN=size(data,1);
N=20;
results=zeros(N,length(10:5:maxN));
for j=1:N
iTemp=1;
for i=10:5:maxN
disp([j i]);
% which=randperm(maxN);
% which=which(1:i);
which=ceil(rand(i,1)*maxN);
newData=data(which,:);
temp=fly... |
function bounding_box = LoadBoundingBox(csv_path)
% Loads bounding box from a csv like pass1.csv produced by the HUD
% when passed the -b option
csv_vals = csvread(csv_path);
last_frame_number = -1;
num = 1;
for i = 1 : size(csv_vals, 1)
% check for duplicate frame numbers
this_frame_number = ... |
function [J grad] = nnCostFunction(nn_params, ...
input_layer_size, ...
hidden_layer_size, ...
num_labels, ...
X, y, lambda)
%NNCOSTFUNCTION Implements the neural network cost func... |
function map = map_constructor(patch_count, patch_size, map_size, name)
maxquality_map = zeros(map_size,map_size);
type_map = zeros(map_size,map_size);
% Generate patches
for i = 1:patch_count
type = ceil(rand()*4);
quality = abs(randn()*0.5);
% Ensure disjunct patche... |
%function r=stateEntropyRate(hmm);
%calculates mean state entropy rate/transition
%for a HMM object or multidim array of HMM objects
%
%Input:
%hmm= single HMM object or multidim array of HMM objects
%
%Result:
%r= matrix with state entropy rates (bits/sample)
% size(r)==size(hmm)
%
%Arne Leijon 2009-07-2... |
clear all
clc
% mu_x = [0; 1; 1; 2];
% Sigma_x = [1 3 4 5;2 2 3 10;1 2 2 4;4 5 5 4];
%
% f = @(x)[pol2cart(x(1:2,:)), pol2cart(x(3:4,:))];
mu_x = [0; 1];
Sigma_x = [1 3;3 10];
f = @(x)pol2cart(x(1,:),x(2,:));
[mu_y, Sigma_y, y_s] = approxGaussianTransform(mu_x, Sigma_x, f);
% [mu_ref, Sigma_ref] = reference.approxG... |
clear
clc
%Cube target
cube = Cube_points(2,[3,7,5],0.5,0.2,0.3); %[x1 y1 z1; x2 y2 z2;...]
T_OC=[eul2rotm([0 0 0]*pi/180) [-7; 5; 12]]; %initial projection matrix - cMw --- 3 Rows, 4 Columns
Tdes_OC=[eul2rotm([10,-7,-15]*pi/180) [-20; 5; 20]]; %desired projection matrix --- 3 Rows, 4 Columns
[xyinit,xydes,kp_ini... |
function [h] = plot_boot(xi,R,varargin)
hold on
lower = mean(R.samples)' - R.ci(1,:)';
upper = R.ci(2,:)' - mean(R.samples)';
h = boundedline(xi,mean(R.samples)',[lower,upper],varargin{:})
hold off
end |
function obj = DirVec2Quat(k, theta)
obj = Quaternion;
% 'k' is direction vector
% 'theta' is the rotation about 'k' [radians]
k = k/norm(k);
q = Quaternion(cos(theta/2), [k(1)*sin(theta/2) k(2)*sin(theta/2) k(3)*sin(theta/2)])
obj = q;
end |
function [ handle ] = PlotTDResponse(times, response)
handle = figure;
handle.Position = [100 100 800 600];
handle.Resize = 'off';
h = plot(times, real(response), '-');
end
|
function [ refine_lines ] = refineLine( lines, img )
% refine lines in image coordinates,
% lines: 5*M matrix M lines
% |x1,x2,y1,y2|;...
[sz1, sz2, ~] = size(img);
refine_lines = lines;
for i=1:size(lines,2)
x1=lines(1,i);
x2=lines(2,i);
y1=lines(3,i);
y2=lines(4,i);
if x1>=1 && x1<=sz2 && x2>=1 &&... |
%% Image segmentation
%
%%
tic
clear all
close all
%% Image 1
%
Im1 = imread('flower.png');
imshow(Im1);
Im1 = double(Im1);
[m,n,~] = size(Im1);
red1 = Im1(:,:,1);
green1 = Im1(:,:,2);
blue1 = Im1(:,:,3);
NewImage = zeros(size(Im1));
%%
%
for i=1:m
for j=1:n
XiMat{i,j} = [i;j;red1(i,j);... |
function sigma = DeNouyjeveaVaga (m, g, r)
a = m*g;
b = 4*r*pi;
sigma = a/b;
endfunction
|
function target = Read_VASP(flag, ID)
%-100: if VASP is complete (Seems not used any more)
% 0: if 1st SCF is done & SCF is converged
% 1: energy/enthalpy
%-1: collect all energy
% 2: pressue tensor
%-2: all pressure tensor
% 3: dielectric constant
% 4: gap
% 5: magmoment
%-5: atomic magmoments
% 6: elastic constant m... |
function [pts_im_part2, pts_world_part2] = CS5320_part2()
% CS5320_part2: Returns the image points by clicking them
% in the image, and corresponding world points.
% Just click six times in the image in the sequence given in A3
% and you would get back the coordinates. Currently I have hardcoded
%to get 6 poin... |
L = 2274;
Fs = 100;
T = 1/Fs;
w = [0.002 .2];
Y = fft(aX);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
plot(f,P1)
bpFilt = fir1(15, w, 'bandpass');
bpOut = filter(bpFilt, 1, aX);
figure();
subplot(2,1,1);
plot(time, aX);
title('raw aX signal');
ylabel('aX');
subplot(2,1,2);
p... |
%% 训练单个传感器数据模型
% add model and util functions to matlab path
addpath('../util');
data_path = '../data/data_without_events.txt';
[data,label] = load_data( data_path );
window_size = 100;
par_1 = get_layer_pars(1,2,1);
par_1.ws = window_size;
par_1.num_trials = 4;
layer_pars = par_1;
step = 200;
sensor_type = 6;
train_d... |
% files=dir('/Users/hernan/eprime/N-back/sound/*.wav');
% for n=1:length(files)
% wavs{n} = wavread(fullfile('/Users/hernan/eprime/N-back/sound', files(n).name));
% %mywavsc(wavs{n}, 40000)
% end
%
% save soundmat
clear all
load soundmat
Nmywavs = 8;
Npos = 8;
Nback = 2
Nsets = 10;
Ntrials = 15;
Nmatches = ro... |
function matr = DrawSolidHead(vertex, tri)
p = trisurf(tri', vertex(1, :), vertex(2, :), vertex(3, :), 0, 'edgecolor', 'none');
light('Position', [0 0 1], 'Style', 'infinite');
lighting gouraud
%axis equal
%axis vis3d
v = p.Vertices;
vertices = int64(v);
tranv = vertices';
xdata = tranv(1,:);
ydata = tranv(... |
% 2011_7_20 盛先
% 8连通域寻找
function I_ind = my_connect_domain(I_bw)
[row, col] = size(I_bw);
% 因为I_bw的周边行列均为0 这是前面算出的先验条件
% 从左上角开始扫描
I_ind = zeros(size(I_bw)); % 存储为1的标号
ind = 1;
for ii = 2:row-1
for jj = 2:col-1
if I_bw(ii,jj) == 1
Top_left = I_ind(ii-1,jj-1) + I_ind(ii-1,jj) + I_ind(ii-1,jj+1... |
% Written by: Asif Iqbal (aiqbal1@student.unimelb.edu.au)
%% KSVD implementation
function [D,W] = K_SVD(Y,D,noIt,s,st,d)
% st = 1st element to be optimized or not, 1 or 2 (starting atom)
if ~exist('st') % to show the dict convergence or not.
d = 0; st = 1;
elseif ~exist('d')
d = 0;
end
K = size(D,2... |
% Plots an oblate spheroid along with basis vectors. This version uses
% the ellipsoid semimajor axis as one of the OS coordinates.
%
% Kurt Motekew
% 2020/04
%
close all;
clear;
% Define Oblate spheroid with fixed size
e = .9; % Shape
a = 3.75; ... |
%This function plots the PV and diabatic/frictional PV terms along
%float tracks in eq40. Flt is the float number to display or float
%numbers to average over.
tic
load('Floats.mat');
fn = Floats3;
cflt = fn(50);
bad = [16 17 51 52 53 66]; %bad with 5-point horizontal
fn(bad) = [];
bad2 = [5 15 25 48]; %bad with 3-po... |
function P = wavStim(P, Prefix);
% wavStim - compute wav stimulus
% P = wavStim(P) computes the Waveform objects from info in P:
% Nwav: the numer of wav files
% wavFileNames: a cell containing the wav locations as in the wavlist file
% WavFileNb: an array of numbers from 1 to Nwav representing
% ... |
function [matrixRadian] = direction(t1matrix,t2matrix,name)%(t1b1,t1b2,t1b3,t1b4,t1b5,t1b7,t2b1,t2b2,t2b3,t2b4,t2b5,t2b7,ano1,ano2)
%matlabpool open
% fazer o 3-d com base no histograma
% x-> magnitude
% y->dircao
% z-> contagem de pixels de determinado valor em magnitude (histograma)
% grafico polar
% NDVI-> fa... |
disp("Running");
A = serialport("COM15",921600);
configureTerminator(A,"CR/LF");
flush(A);
% Variables
button = zeros(1,4); % Button Values
encval = zeros(1,12); % Encoder Values
receive = zeros(1,16);
% Main Loop
% while(true)
% if (readline(A) == "Start")
% disp("Looping");
% break
... |
function fse3d_recon2(Pfile , x,y,nechos,nframes)
%function fse3d_recon2(Pfile , xdim, ydim, nechos, nframes)
%
% reconstruction of stack of spirals data using gsp20a for
% x and y directions and doign the third direction by hand.
% assumes that the P file header info thinks that there is only
% one slice.
%
str=spri... |
function [ output ] = cuckoomove(eggs,input,label,tp,sv,nc)
[m,n]=size(eggs);
for i=1:nc
a=randi(m);
b=randi(m);
while (eggs(a,n-2)==eggs(b,n-2))
b=randi(m);
end
d=randi(n-3);
egg=eggs(a,:);
for j=1:d
egg(1,randi(n-3))=eggs(b,randi(n-3));
end
egg=score(e... |
function [leadVal, lagVal]=leadlag(price,lead,lag,flag)
%%
if ~exist('lead', 'var') || isempty(lead), lead = 10; end
if ~exist('lag', 'var') || isempty(lag), lag = 30; end
if ~exist('flag', 'var') || isempty(flag), flag = 'e'; end
%%
% 计算快速线和慢速线
leadVal = ind.ma(price, lead, flag);
lagVal = ind.ma(price, lag, flag)... |
%%Convert LocCentroid particle position data into a format for the
%%georgetown tracking code.
function xyzt = struct2list(LocCentroid);
structlength = length(LocCentroid);
numpart = length(LocCentroid(1, 1).time(:,1));
xyzt=[];
for L = 1:structlength
leftoff = length(xyzt);
numpart = length(LocCentroid(1, L... |
function [ splines, eindices ] = uvEdge( uInd, vInd, V, E, adjList )
%UVEDGE finds the spline edge with vertices u and v, if it exists.
%
% INPUTS
% uInd: (integer) index of the vertex endpoint u of interest.
% vInd: (integer) index of the vertex endpoint v of interest.
% V: (cell array of (dx1) vertex coordinates) ver... |
%Function to find the effective impedance
%Multiple slabs: Slight change, not much
function [Zprev] = effectiveImpMS(N, ZL, Zedge, Zinf, ZTx, dzud, dz, k, TotSlabs, SlabNum)
Imp_Iter = 1:2*N+2;
Z_iter = zeros(size(Imp_Iter));
%ZL = Zin;
Zprev = 0;
for iter = Imp_Iter
if(mod(iter, 2)==1)
... |
function [input,target_input] = class_balancing(P,Trg)
% a number of interictal points at most equal to the sum of the points of the other classes
ictal_class = find(Trg(:,3) == 1);
pos = 1;
beginning_ictal(pos) = ictal_class(1);
for i=1:length(ictal_class)
if(i == length(ictal_class))
end_ictal(pos) = ic... |
% Rozdělení dat metodou nerovnoměrné binární dělení do určeného počtu tříd
function [ a, b, c ] = nerovnomerne_binarni_deleni( data, R )
% data = mnozina obrazu
% R = počet tříd
data_size = size(data);
tridy2 = zeros(data_size(1), (R * 2) - 2);
zkresleni = zeros((R * 2) - 2,1);
stredy = zeros(2, (R * 2) - 2);
data_tmp... |
audio_vector = audioread('music.au');
%sound(audio_vector)
sig1 = audio_vector(1:2:end);
subplot(2,1,1)
plot(sig1)
title('sig1')
xlabel('t')
ylabel('sig1')
%sound(sig1)
h = fir1(20, [1/2]);
filterOut = conv(audio_vector, h);
sig2 = filterOut(1:2:end);
%sound(sig2)
subplot(2,1,2)
plot(sig2)
title('sig2')
xlabel('t')... |
clear
clc
searchFolder = '\\root\projects\AmericanCancerSociety';
fileArray = recursiveFileSearch(searchFolder); |
function [output] = RGBThreshold(input,thresholds)
% Function that performs color image thresholding using
% user-defined threshold values. Emphasises red areas.
% Inputs:
% input - Input image
% thresholds – 1x3 matrix with the threshold values
% for the R, G and B color channels.
% Output:
% output - Output image (bi... |
function idx = findClosestCentroids(X, centroids)
K = size(centroids, 1);
idx = zeros(size(X,1), 1);
dist = zeros(size(X,1), K);
for i = 1:K
diff = bsxfun(@minus, X, centroids(i,:));
dist(:,i) = sum(diff .^ 2, 2);
end
[dumb idx] = min(dist, [], 2);
end |
Fs=12000
N=0.5*12;
n=0:N-1;
figure(1)
t=0:0.1:0.5;
s=abs(sin(pi*t*10/2))
%semnal binar aleator (valori 1 sau 0)
%reprezint semnalul continuu in timp absolut folosind functia plot
plot(t,s)
grid
figure(2)
s=abs(sin(pi*n/2))
%reprezint semnalul discret in functie de n folosind functia stem
stem(n,s)
grid |
% clear variables
%% Main Script...
clc;
clear;
%% Set parameters
enable_plot = 1; % 0 = OFF, 1 = ON
%% Read the testing image
% testImages = ["barbara","baboon","goldhill","peppers","lena","1920test1","1920test2"];
% testImages = ["barbara"];
testImages = ["1920test2"];
% plotImagename = "goldhill"; % one image to... |
function exectime = matmult(n)
a = rand(n, n, 'single');
b = rand(n, n, 'single');
tic
for i=1:5
z = a * b;
end
exectime = toc;
|
clc;clear;close all;
%%
load('Model.mat');
Degree=3;
%% PSO
disp('Starting PSO ...');
%%
nVar=Degree+2; % Number of Decision Variables
VarSize=[1 nVar]; % Size of Decision Variables Matrix
Alpha=0.75;
VarMin=-(10^Alpha);
VarMax=10^Alpha;
%% PSO Parameters
MaxIt=1000; % Maximum Number of Iteratio... |
function [output] = PSK_Function(db)
i=10;
j=5000;
t=linspace(0,5,j);
fc=10;
fm=i/5;
B=2*fm;
error=0; %存取错误码元的个数
for echo=1:1:1000 %一共循环echo个周期
a=round(rand(1,i));
st1=t;
for n=1:10
if a(n)<1
for m=j/i*(n-1)+1:j/i*n
st1(m)=0;
end
else
for m=j/i*(n-1)+1:j/i*n
... |
function g = sigmoid(z)
%SIGMOID Compute sigmoid functoon
% J = SIGMOID(z) computes the sigmoid of z.
% You need to return the following variables correctly
g = zeros(size(z));
% ====================== YOUR CODE HERE ======================
% Instructions: Compute the sigmoid of each value of z (z can be a matrix,
... |
function result = asl_spm03(args)
%
% function result = asl_spm02(args)
%
% (c) 2010-2019 Luis Hernandez-Garcia @ University of Michigan
% report problems to hernan@umich.edu
%
% This function processes ASL data from a raw k-pace file to a
% QUANTITATIVE PERFUSION ACTIVATION map of the deisred effects
%
% some notes: ... |
%------------------------------------------------------------------------
% df_read: 18-10-07. Reads Philips DF files
% SJM. USAGE: image = df_read('filename');
%------------------------------------------------------------------------
function im = df_read(filename)
% 22-11-10: only add .df if not presen... |
function [t_rh,rh_invjs,rh_invpre,rh_stats,rms_js,rms_pre] = invsnr_plot(startdate,enddate,invdir,kspac,tlen,...
plotl,tgstring,rhlims,plotrh,plotvdc)
%%
% this codes takes the output from invsnr.m and plots it and compares with
% a tide gauge (if there is one)
% INPUTS
% startdate: in datenum format
% enddate: ... |
%==========================================================================
% conductance_parameter.m
% Author: Akira Nagamori
% Last update: 9/18/19
% Descriptions:
%==========================================================================
close all
clear all
clc
code_folder = '/Users/akira/Documents/GitHub/MN-Mode... |
function [net, info] = cnn_dicnn(varargin)
%CNN_DICNN Demonstrates fine-tuning a pre-trained CNN on imagenet dataset
%it is good job in your code!
run(fullfile(fileparts(mfilename('fullpath')), ...
'..', 'matlab', 'vl_setupnn.m')) ;
% 修改读入文件夹的路径
opts.dataDir = fullfile('data','image') ;
opts.expDir = fullfile... |
% Saisie des donn?es 2D et 3D ? partir des vues des 2 cam?ars et de l'objet 3D de calibrage connu
%
% Made in TRIBOULET 2008
%
clear;clc;close all;
% Nombre de points de calibrage sur chaque prise de vue de l objet 3D
npts_calib=12;
% Observer l ordre des points propose dans le TP
xyz... |
if ~exist('fc_fuel_map')
%%%% DDC Data %%%%
% (rad/s), speed range of the engine
fc_map_spd_ddc=[1200 1400 1600 1800 2000 2100]*pi/30;
% (N*m), torque range of the engine
fc_map_trq_ddc=[100 200 400 600 800 1000 1200 1400 1600 1800 2000];
% (g/s), fuel use map indexed vertically by fc_map_s... |
%{
ECE 4333 - Robotics project PixyCam calibration data
Eric Henderson | Burak Koryan
April 2019
Variable Descriptions:
x & y : Coordinates of recognized color blcok
w & h : actual width and height of the color block
r : distance of the color block to PixyCam
MeansW : An array of mean of widths for all measurement... |
%---------------------------------------------------------------------------
%
% M-file: fc_numcells
%
% If N, number of cells in the stack is zero, the number of cells is
% calculated
%
% Kristina Haraldsson, NREL
% Date: 082602
%---------------------------------------------------------------------------
function f=... |
function [Magnitude, Phase, f] = FourierAnalysis(sourcedata, Fs)
L = length(sourcedata); % Sampling points
t = (0:L-1)/Fs;
N = 2^(nextpow2(L)+0); % Sample point
% More points, more accurate Fast Fourier Transformation
N = L;
Y = fft(sourcedata);
f = Fs/N*(0:N-... |
%% Machine learning class final project
% Support vector machine final project
% One main challenge of this binary classification project is the
temp = matlab.desktop.editor.getActive;
cd(fileparts(temp.Filename));
clear all; close all; clc
%% SVM with features weighted as important using feature selection algorithm
... |
% This file compiles CVode for use with MATLAB
chooseCompiler;
mkdir( [cvodeDir '/tmp'] );
% List of directories to include in the compilation
list = { 'cvodes' 'nvec_ser' 'sundials' };
% Make a list of filenames to include in the compilation
names = '';
sourceDir = [ parserDir 'CVode/' ];
for q = 1 : lengt... |
% $Header: svn://.../trunk/AMIGO2R2016/Kernel/OPT_solvers/NGPM_v1.4/TP_NSGA2/TP_ZDT4_objfun.m 770 2013-08-06 09:41:45Z attila $
function [y, cons] = TP_ZDT4_objfun(x)
% Objective function : Test problem 'ZDT4'.
%*************************************************************************
y = [0, 0];
cons = [];
g = 1 + ... |
baseperiod=[3000 4000];
markerdict=struct('marker',[31 34 37 ],...
'label', {{'seq_NO1', 'seq_AM1', 'seq_IM1', }});
labels ={{{'seqfull1'}}};
sliceraw_anthesia_powerfull
markerdict=struct('marker',[32 35 38 ],...
'label', {{'seq_NO3', 'seq_AM3', 'seq_IM3', }});
labels ={{{'seqfull3'}}};
sliceraw_anthes... |
%% Plot example sessions for procedure
rng(mean('hyperalignment'));
%%
% Pair of 2 and 9 is the highest z-score asymmetry pair.
sr_i = 1;
tar_i = 10;
idx = {sr_i, tar_i};
data = Q;
[~, max_sr_idx] = max(data{sr_i}.right, [], 2);
[~, sorted_sr_idx] = sort(max_sr_idx);
[~, max_tar_idx] = max(data{tar_i}.right, [], 2);... |
clear; clc; setup; config_scaling_reflector;
%% ! WIT/WPT vs number of IRS elements
witWfSample = zeros(nChannels, length(Variable.nReflectors), 2);
wptAssSample = zeros(nChannels, length(Variable.nReflectors), 2);
wptSmfSample = zeros(nChannels, length(Variable.nReflectors), 2);
wptSdrSample = zeros(nChannels, length... |
clear; clc;
warning off;
addpath(genpath(pwd));
basePath = './大力小力/';
dirs = dir(basePath);
begin=30*8 + 1;
tail=begin+29;
for x=1:size(dirs, 1)
if (dirs(x).name(1) == '.')
continue;
end
fprintf('%s-> ', dirs(x).name);
load([basePath, dirs(x).name, '/hard/hard_decimatedata_0.6k... |
function out = powerSpecDen(x, frame_size, overlap, winType)
%{
Inputs:
x: (array) : 1D time sequence
frame_size: (int) : size of one frame
overlap: (int) : size of frame overlap
Returns:
out: short time fourier transform
%}
N = length(x);
if rem(N,frame_size) > 0
... |
function difference = asympt_diff( params, C, xspan )
xleft = xspan(1);
xright = xspan(2);
intervals = 2^10;
eps = 1e-6;
init_left = [asympt_left(params, C, xleft)
(asympt_left(params, C, xleft + eps) - asympt_left(params, C, xleft - eps)) / (2 * eps)];
[~, U] = f_solve(params, [xleft 0], init_left, int... |
function [TF] = RC_transferFunction(f,Rs,a)
% Last Update: 07/07/2019
%% Calculate Passing and Decaying Bands
passBand = abs(f)<=(1-a)*Rs/2;
decayBand = abs(f)>(1-a)*Rs/2 & abs(f)<=(1+a)*Rs/2;
%% Apply RC Transfer Function
TF = zeros(size(f));
TF(passBand) = 1;
TF(decayBand) = 0.5*(1+cos(pi/(a*Rs)*(abs(f(decayBand)... |
function Q = compflwEmbedded(k,PR,U_c,k_a,R_a,T_amb,c_pa,d_c) %#eml
% Q = COMPFLWEMBEDDED(k,PR,U_c,k_a,R_a,T_amb,c_pa,d_c)
% Used in the embedded matlab function of the engine.
% Calculates the volume flow for the modeled compressor.
%
% Data:
% k : coefficients of the model
% PR : pressure ratio... |
x=[0 1 2 3 2 1];
h=[1 1 1 1 1 1];
nx=(0:1:5);
nh=(0:1:5);
subplot(3,1,1);
stem(nx,x);
xlabel('n');ylabel('x(n)');
title('signal x(n)');
subplot(3,1,2);
stem(nh,h);
xlabel('n');ylabel('h(n)');
title('signal h(n)');
n=(0:1:length(x)+length(h)-2);
subplot(3,1,3);
c=conv(x,h);
stem(n,c,'k');
xlabel('n');
ylabel('x(n)');
t... |
function varargout = SeriesAnalyzer(varargin)
% SERIESANALYZER MATLAB code for SeriesAnalyzer.fig
% SERIESANALYZER, by itself, creates a new SERIESANALYZER or raises the existing
% singleton*.
%
% H = SERIESANALYZER returns the handle to a new SERIESANALYZER or the handle to
% the existing singleton... |
%Para ejecutar solo correr la funcion y darle el numero de grado de
%ecuacion
function a = Ajuste_minimos_cuadrados ()
g = input('\n Ingrese el grado:\n');
x = [1,2,3,4,5,6,7]';
y = [0.5, 2.5, 2, 4, 3.5, 6, 5.5]';
N = length(x);
M = ones(N, 1);
for k=1:g
M = [M,x.^k];
disp(M);
... |
function FE = XO2FE(XO)
FE = [0.01, 0.01, 0.01, 0.01, 0.01, 0.01];
for j = 1:6
T = XO(1,j);
if strcmp(T,'x')
FE(1,j) = 1.0;
end
end
end
|
function net = createNetwork(vettoreStrati,vettoreFunzioni,pesi)
nStrati = length(vettoreStrati) - 1;
w = cell(1,nStrati);
b = cell(1,nStrati);
dim1 = vettoreStrati(1);
for strato = 1:nStrati
dim2 = vettoreStrati(strato+1);
w{strato} = pesi - (2*pesi)*rand(dim2,dim1);
... |
% Read the voice file.
[x1,fs] = audioread('yanchanghuitest.mp3');
%Convert the voice from double channels to single channel.
if length(size(x1))>1
x1 = x1(:,1);
end;
%Plot the voice waveform in the time and frequency domains.
figure(1);
plot(x1);
title('The voice in the time domain');
xlabel('Time(second)');
yl... |
%% Set initial info and function
initSeed = 1;
% Time and area
L = 15; XInt = [-L,L];
T = 1; TInt = [0,T];
% Numerical precision, number of points
N = 2^9; % Time
M = 2^7; % Space
h = (TInt(2)-TInt(1))/N;
dx = (XInt(2)-XInt(1))/M;
% alpha = 1;
% q = 1;
% c = 1;
% u0Fun = @(x) sqrt(2*alpha/q)*exp(0.5*1i*c*x).*sech(sq... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.