text stringlengths 8 6.12M |
|---|
function [y, h, n] = degradation(x)
[a, b] = size(x); %Size of the input image
y = zeros(a,b);
%degradation kernel
h = fspecial('motion', 42, 30);
%white noise
n = randn(a,b) * sqrt(0.001);
%apply the kernel to the input
y_inter = imfilter(x, h, 'replicate', 'same', 'conv');
%add ... |
function [patterns, targets, UW, m, W] = PCA(patterns, targets, dimension)
%Reshape the data points using the principal component analysis
%Inputs:
% train_patterns - Input patterns
% train_targets - Input targets
% dimension - Number of dimensions for the output data points
%
%Outputs
% patterns - New patt... |
function [option,i] = chooseoption(optionlist,varargin)
%% [option,i] = chooseoption(optionlist,selection)
% selection:
% 1 - choose only one option
% 2 - choose multiple options
% string = display string questions. i.e. chooseoption(optionlist, 'choose volume')
% then 'choose volume' would be displayed before option ... |
function [B] = diagb(A,area,n_area)
% Syntax: [B] = diagb(A,area,n_area)
%
% Purpose: Set the off-diagonal blocks of the matrix A equal % to 0.
%
% Input: A - a square matrix
% area - a matrix defining the block diagonal
% structure of A.
% n_area - a vector containing the number o... |
function [x y] = genPlayer(nr)
%GENPLAYER Summary of this function goes here
% Detailed explanation goes here
% Liefert [x y] des panzers.
% wenn nr >1 dann ist der panzer invers (Player L und Player R)
%simpler "panzer":
x=[0 10 10 4 4 3 8 7 2 0 0];
y=[0 0 6 6 10 10 16 17 10 10 0];
x=x-4; % in mitte posi... |
function triplets = tripletGenUnique(X, num_const)
% TRIPLETGENUNIQUE generates unique synthetic triplets
%
% triplets = tripletGenUnique(X, num_const)
%
% Function tripletGenUnique generates synthetic triplets based on the
% features in X such that each triplet is only satisfied in one of the
% feature spaces. For e... |
function Z_Coord = FRONT_Tips2World( Front_tips, ...
front_geometric_features, ...
WORLD_Measures )
%FRONT_TIPS2WORLD Computes Real World Coordinates of each Finger Tip
% OUTPUTS:
% * Z_Coord - vector of coordinates of finger tips in real worl... |
close all
clear
clc
% Deterministic
tau0 = 3.15;
lamD = lambertw(0, -0.5*tau0)./tau0;
lamD = real(lamD);
lamSdD = 0;
disp(['Deterministic lamda = ', num2str(lamD), ' SD = ', num2str(lamSdD)])
va = 0.5;
% MC
alpha = 2;
beta = 2;
n = 1e4;
ksi = betarnd(alpha, beta, n, 1);
tauM = tau0 + (2*ksi - 1)*va;
lambda = lambertw(0... |
% Latent heat flux
% exGas.dmCond.H2O = 0 => hCond(i) = 0
hCond(i) = exGas.dmCond.H2O(i) * r_H2O(exGas.t.b(i));
% Exhaust gas mass flow rate [kg/s]
exGas.m.all(i+1) = exGas.m.all(i) - exGas.dmCond.all(i);
% Mass flow rates [kg/s]
exGas.m.H2SO4(i+1) = exGas.m.H2SO4(i) - exGas.dmC... |
% rf_predict(forest_ptr, data_mtx)
% Uses the forest pointed at by forest_ptr to predict values for everything in data_mtx.
% data_mtx must have one row per sample (one column per feature) as with training. |
table_t; table; Fst = 800;
figure(900);
sumMaxCorrx = 0; % sum of maximum cross-correlations x*y
sumMaxCorry = 0; % sum of maximum auto-correlation x*x
for i = 2:10
i
fss = min(Fs/2, 12);
tablex = table{i}(1:end-1); tablet = table_t{i}(1:end-1);
x = nikCell{i}; t = nikCell_t{i};
[t ind] = unique(t... |
function CSD = computeCSD(ops, varargin)
% check if argument 1 is a path or an ops
if ~isstruct(ops)
fdir = ops;
ops = io.loadOps(fdir);
end
ip = inputParser();
ip.addParameter('method', 'standard')
ip.addParameter('window', [-.1 .25])
ip.addParameter('binSize', 1e-3)
ip.addParameter('verbos... |
% EMTH171 // CaseStudy2
% Name: Menghao Zhan // Jiyao Zhu
clear
clc
close all
%====================--Constant Values--======================
g = 9.81; % Coeficience of Gravity(m/s^2)
tarray = 1:1:8760; % One year shown by array (hours)
Stand_d = 1000; % Standard deviation (h)
Mean =... |
clear all;
lambda = 0.7;
N = 1000;
for i = 1 : N
U = rand;
X(i) = 0;
while U >= exp(-lambda)
U = U * rand;
X(i) = X(i) + 1;
end
end
fprintf('simulated probab. P(X = 2) = %1.5f\n', mean(X == 2))
fprintf('true probab. P(X = 2) = %1.5f\n', poisspdf(2, lambda))
fprintf('error = %e\n\n', ab... |
close all;
clear all;
load("Results_1D_Simulation_Force_plot2.mat");
n = 10; % Number of points on chain
% Finding max value
max_val = max(P_1d_dynamics_force(1,:,:),[],'all');
% Finding min value
min_val = min(P_1d_dynamics_force(1,:,:),[],'all');
% max_temp = 10^5;
% T_vals = [298:402:max_temp];
F_app = [0:2... |
function tf = isTextStrict(value)
tf = (ischar(value) && ((isempty(value) && isequal(size(value),[0 0])) || isrow(value))) || isstring(value) || iscellstr(value);
end
|
classdef Sanya < SWEWDPreBlanaced2d
properties(Constant)
%> wet/dry depth threshold
% hmin = 0.5
%> gravity acceleration
% gra = 9.8
%> interval of tide elevation (s)
tideinterval = 600
%> tidal elevation of open boundary vertices
tidalFile = ...
... |
im = zeros(100,100);
im(25:75,25:75) = 1;
im(15:23,25:75) = 1;
im(24,45:50) = 1;
i3=im;
i2 = im;
mask = ones(3,3);
for i = 2: 99
for j = 2: 99
neigh = i2(i-1:i+1,j-1:j+1);
im(i,j) = min(neigh(logical(mask)));
end
end
i2 =im;
for i = 2: 99
for j = 2: 99
neigh = i2(i-1:i+1,j-1:j+1);
im(i... |
clc
clear all
close all
n = input('give no. of terms: ')
sum= 0;
for k=1:n
sum=sum+(k*power(-1,k)/power(2,k));
end
disp('The final sum is=')
disp(sum) |
function img = micsoreazaLatimeEliminaObiect(img,ploteazaDrum,culoareDrum,xmin,ymin,xmax,ymax)
numarPixeliLatime = xmax - xmin + 1;
for i = 1:numarPixeliLatime
disp(['Eliminam drumul vertical numarul ' num2str(i) ...
' dintr-un total de ' num2str(numarPixeliLatime)]);
%calculeaza energia dup... |
%{
[~,~,~,~,~,~,~,B]=Bmatrix(0.5, 5);
B1=B';
[~,~,~,~,~,~,~,B]=Bmatrix(0.25, 5);
B2=B';
lambda1=eig(B1);
lambda2=eig(B2);
l1=abs(lambda1);
l2=abs(lambda2);
sort(l1);
l1=sort(l1);
l2=sort(l2);
m=5;
delta=0.25;
h=delta/m;
n=1/h;
beta=2*ones(1,m-2);
beta=[1/3,5/3,beta,(5-3*m)/3,(1-3*m)/3];
beta=h^2/(delta^2)*beta;... |
%Problem 9
m = csvread('exampleSignal.csv',3,0);
figure;
plot(m);
figure;
findpeaks(m);
|
% butte ΒΛ²¨ΖχΙθΌΖ³ΆΚΤ
fs = 10000;
fmax = fs/2;
wpass = 1500;
wstop = 1700;
Wp = wpass/fmax;
Ws = wstop/fmax;
[n,Wn] = buttord(Wp,Ws,3,60);
[b,a] = butter(n,Wn);
freqz(b,a);
|
function ExpandedImage = Expand(Image, Dimensions)
% This function expands an image size by 2.
ExpandedImage = zeros(Dimensions, class(Image));
ExpandedImage(1 : 2 : end, 1 : 2 : end, :) = Image;
ExpandedImage = 4 * imfilter(ExpandedImage, Kernel());
end
|
function [] = tuning_TT(cellname)
%
% makes and saves the variable and tuning (including activity trial by trial).
% several tuning curves are computed:
% byoffertype: distinguishes offertypes
% bytrialtype: distinguishes A/B choices -- most of the analysis based on this.
% by trial: trial by trial.
%
% author: cami... |
function outpath=addbox(boxname)
% addbox(boxname,type)
% adds toolbox paths to matlabpath.
% if 'type' is specified, can also be used to add input data paths
% uses defpaths for definition of basic paths
outpath='';
path_common='./COMMON/'
try
outpath=genpath(fullfile(path_common, boxname))
addpath(outpath);
... |
function img = vuGenerateMetaImage(data, spc, origin)
% vuGENERATEMETAIMAGE Generate a meta image structure
% SYNTAX:
% META_IMG = vuGenerateMetaImage(DATA, SPC, ORIGIN) generates the
% meta image structure, META_IMG. DATA is an MxN or MxNxP matrix of
% the image data for 2D or 3D images. SPC is a... |
a=[1 2 2; 3 1 2; 6 3 2]
a=a(:)
[p i]=min(a(:))
[l m]=ind2sub(size(a),i) |
function create_feature_matrices_selected_features()
project_path = '/Users/burakonal/Desktop/edu/ee-58j/project';
fname = fullfile(project_path, 'attribute_data', 'apascal_train.txt');
[img_names_apascal_train, img_classes_apascal_train, bbox_apascal_train, ~] = read_att_data(fname);
fname = fullfile(p... |
function [w, mean, sd] = UpdateGMM(w, mean, sd, alpha, pixval)
if nargin < 5
w = (1 - alpha) * w;
else
w = (1 - alpha) * w + alpha;
mean = (1 - alpha/w)*mean + alpha/w * pixval;
sd = sqrt((1 - alpha/w)*sd*sd + alpha/w *(pixval - mean)*(pixval - mean));
end
|
%% Matlab for Brain and Cognitive Scientists
% Matlab code for Chapter 26
% Mike X Cohen
%
% This code accompanies the book
% "Matlab for Brain and Cognitive Scientists" (MIT Press, 2017).
% Using the code without following the book may lead to confusion,
% incorrect data analyses, and misinterpretations of res... |
function flag = value_function3_test_NDD( range,range_rate,v,a_list )
flag = 1;
state = [range,range_rate,v];
for i = 1:size(a_list,1)
[state,reward] = update_state_test(state,a_list(i));
if reward == 1
flag = 0;
end
end
end
|
clc
clear
close all
%%%%%%估计参数
% Read_Display_Data
tic
N=10000;
L=21;
R = fun_rho(0.9,N,1,0.1);
[Train,tauk] = fun_TrainData('g',N,L,R);%%产生的训练数据,协方差矩阵为rouR的高斯杂波
parfor i = 1:10000%nsweep
[lambda(i),mu(i)] = fun_IG_ML(Train(i,:));
end
mean(lambda)
mean(mu)
toc
% MTD = abs(fftshift(fft(sig,[],1)));
% mesh(MTD)
% s... |
% ADVISOR Data file: FC_INSIGHT.M
%
% Data source:
% Fuel map from test data provided by Argonne National Laboratory (ANL)
% Emissions maps are not included in this data file.
%
% Data confidence level:
%
% Notes:
%
% Created on: 10/26/00
% By: Ken Kelly, National Renewable Energy Laboratory, ken_kelly@nrel.go... |
function [ncc] = getNCC(img1, img2)
%getNCC This NCC is meant for strip registration
% Originally written by Dr. Alf Dubra
% Adapted for this project by Alex Salmon
% roundoff threshold
threshold = 1e-6;
% Make sure img1 is smaller than img2
if numel(img1) > numel(img2)
tmpImg = img2;
img2 ... |
function s=s_open(str)
%Opens the serial port
o=instrfindall;
delete(o)
%------------------------------------------
serialPort = str;
s = serial(serialPort);
s.Baudrate=115200;
s.StopBits=1;
%s.Header='S';
%s.Terminator='E';
s.Parity='none';
s.FlowControl='none';
if (s.Status == 'closed')
disp('hi')
s.BytesAvai... |
%PLOT_FIGHTER Plot fighter target
%
% Syntax:
% plot_plane(target,x,q)
%
% In:
% target - Target structure
% x - Position as 3x1 vector (optional, default [0;0;0])
% q - Orientation as 4x1 unit quaternion
% (optional, default [1;0;0;0])
%
% Out:
% -
%
% Description:
% Plot the fighter ... |
function out = tcaDynamicsAgain(t,x,F,T,V)
%attempting to figure out the full dynamics including the twisting
%angle phi
%incorporates the thermal and dynamics model
temp = x(1);
delta = x(2);
delta_dot = x(3);
phi = x(4);
phi_dot = x(5);
density = 1300; %density
C... |
function [data] = a_import(date)
%%A_IMPORT(date) imports an A file from date. Date can be given as a
%%date vector [yyyy,mm,dd], a datenum, or as a filename
%
% Written By: Michael Hutchins
%% Filepaths
subdirectory = 'Afiles';
prefix = 'A';
suffix = '.loc';
%% Initialize variables
gz = false;
%% Check for... |
function [SOut, IOut, ROut] = DiseaseStep(SIn, IIn, RIn, N, a, b, h)
%% Step 1
% Those equation was given in week 1.
% All you need to do is to calculte new S, I, R using
% SIn, IIn, RIn.
% All the equations given
% dS = (-a * S * I) / N
% dI = (a * S * I) / N - I / b
% dR = I / b
% N = S + I + R
% To update the ... |
function zi=Zv(T,P,comp,K,y)
% global countrtz
% countrtz=100;
R=8.314;
b=.07779*R.*comp.Tc./comp.Pc;
bm=sum(b.*y);
a=.45724.*(1+(.37464+1.54226.*comp.w-.26992.*comp.w.^2).*(1-(T./comp.Tc).^.5)).^2.*R^2.*comp.Tc.^2./comp.Pc;
am=0;
for i=1:size(y,2)
for j=1:size(y,2)
am=am+(a(j)*a(i))^.5*y(j)*y(i)*(1-K(i,j))... |
clear all;
clc;
cost=10
price=12
a = price — cost * 2
b = 15 + price — 3 * 2
c = (price + cost) * 3
d = 4 — 3 * 2 + cost
e = cost * ((price — 8) + 5) + 100
% question 6a
% Cody
height_ft = input("please enter your height in ft\r\n")
weight_lb = input("please enter your weight in lbs\r\n")
height_cm = height_ft*1... |
function res = animate_results(Time, S, axes, radii, dims, K_tot, ...
speeds, pocket_radius, init_theta, init_speed)
felt_color = [10, 108, 3]./255;
ball_colors = {'w', 'k', [224 102 102]/255, [246 178 107]/255, [103 78 167]/255};
% Make animation stay on last frame for a bit
S = [S; S(end... |
function [tau,W,Wd,Wmd,Pdd,Pcdd,Rici,Rij,Rot] = NewEul_Aux(N,L,m,I,fv,fc,g,q,qd,qdd)
%% Gear reduction ratio
kri = 100;
%% Rotor inertia
Im = 0.01;
%% Rotor mass
mm = 0.5;%0.5;
[W,Wd,Wmd,Pdd,Pcdd,Rici,Rij,Rot] = NewEulForw(N,L,g,kri,q,qd,qdd);
tau = NewEulBack(N,m,I,mm,Im,kri,q,qd,qdd,fv,fc,W,Wd,Wmd,P... |
% #########################################################################
% TUHH :: Institute for Control Systems :: Control Lab
% #########################################################################
% Experiment CSTD1: Identification and Control of a Torsional Plant
%
% Copyright Herbert Werner and Hamburg... |
b = bar(round(holdout,2));
for i=1:length(b) % loop through series (grouped by rows)
for y = 1:2 % datatip each row in this series
datatip(b(i),'DataIndex',[y]); % create datatip
end
b(i).DataTipTemplate.DataTipRows(1) = []; % remove x coord from datatip
b(i).DataTipTemplate.DataTipRows.Label = ... |
% make figures for greedySearch stuff, for 5x more neurons
%% load the folder containing data
cd ('C:\Users\Shreejoy\Desktop\shreejoy\neural_diversity\ST_machinelearn\reconKP\populationsims\greedySearch\finSims\sim2');
% load data from greedySearch iterations across stimuli
% these get stored in bestPop
fileLists = ... |
function[prediction_final75,prediction_final25] = voting_scheme(prediction_overall75,prediction_overall25)
[number_of_types,c] = size(prediction_overall75);
prediction_final75 = cell(1,c);
for j = 1:c
for i = 1:number_of_types
prediction_final75(1,j) = {[prediction_final75{1,j} ... |
function obj = threshold(obj, input_threshold, thresh_type, varargin)
% Threshold image_vector (or fmri_data or fmri_obj_image) object based on
% raw threshold values. For statistical thresholding, convert to a
% statistic_image object and see the threshold method for that object.
%
% :Usage:
% ::
%
% obj = threshol... |
load Dataset4.mat
free_code;
C = [1,0,0,0;0,0,1,0];
my_sys = c2d(ss(A,B,C,D),fSamplingPeriod);
Ad = my_sys.A;
Bd = my_sys.B;
Cd = my_sys.C;
Dd = my_sys.D;
my_poles = pole(my_sys);
Kd; % remainder to me that we have this.
% Choose some reasonable poles
L_poles = exp(Kd*fSamplingPeriod*4);
Ld = place(Ad', Cd', L_pole... |
function VmD = VmDCalculator(VimD, H_Segment, WeightRatio)
% This function calculates the predicted minimum drag velocity from the
% target VimD for a given altitude. It also takes into account the changes
% in weight there would have been until this segment. The weight ratio is
% the product of all the weight frac... |
function output = convolution(image,kernel)
% Filp the kernel
flippedKernel = flip(flip(kernel,1),2);
% Finding the dimentions of the image and the kernel
imageSize = size(image);
kernelSize = size(kernel);
% Finding the ouptut dimention
outputSize = imageSize-kernelSize+1;
output = zeros(outputSize);
... |
function model = addHydrogensAndCharge(model)
fprintf('Storing formation energies of model species\n');
model.majormsCharge = zeros(size(model.mets));
model.nstdInChICharge = zeros(size(model.mets));
model.nstdInChInH = zeros(size(model.mets));
model.nstdInChIFormula = cell(size(model.mets));
for n = 1:length(model.m... |
function prepareBC(fileID,SaveModel)
% sort the original bc the same way
fprintf(fileID,'ori_all = zip(x,y,vx,vy); \n');
fprintf(fileID,'ori_sort = sorted(ori_all, key=itemgetter(0,1)); \n');
fprintf(fileID,'del ori_all; \n');
fprintf(fileID,'oriclean=[]; nodemsk = []; \n');
fprintf(fileID,'for ... |
function result = read_test(dataset_name, vocabulary)
% function result = read_training(dataset_name, vocabulary)
dirname = dataset_directory(dataset_name);
filename = labels_filename(dataset_name);
number_of_classes = numel(vocabulary);
lines = number_of_lines(filename);
test_size = lines - number_of_classes... |
addpath('./glob/');
path2datedirs='/data/cpu-b000-hp01/cryo_data/data2/';
numberSamples = 33554432;
Fs = 2.4e6; % processing rate
Nphi0 = 4; % no. of phi0 swept per flux ramp
Fr = 250; % flux ramp reset rate
Fc = Fr*Nphi0; % flux ramp carrier rate
frameSize... |
function fft_sample = read_in_wave(num_samples, filename)
[samples, Fs] = audioread(filename, [1,num_samples]);
disp(samples);
fft_sample = fft(samples);
disp(fft_sample);
disp(length(fft_sample)); |
close all
clear, clc
s = 'Perceptron Model ( Basit Algılayıcı Model )';
p = [ 2 2 2 1 6 -3 -1 2 -2 -4;
1 -2 -3 -4 -6 3 -4 4 -4 -6 ]
t = [ 1 1 1 1 1 0 0 0 0 0 ]
lamda = 0.1;
w = [0 0]; %rand(1,2);
b = 0; % rand;
fprintf('%s\nLamda = %g\n',s,lamda)
fprintf('w1 = %g, w2 =... |
function [corrps_wg, uncorrps_wg] = perm_test_tInt_chgs(nPerm, chg_IUInt, chg_IYInt, chg_IU2Int, ...
chg_IY2Int, chg_IU3Int, chg_IY3Int, varargin)
%% Optional input arguments
% --permfile: .mat file name for saving perturbation results
%
%% Constants
perts = {'accel', 'decel', ... |
% (a) and (b) PCA
% dimensions to keep
m = 2;
[~,~,~,~,W] = PCA(...
[X_given_setosa_training; X_given_versicolor_training; X_given_virginica_training]', [], m);
X_pca_given_setosa = (W * X_given_setosa_training')';
X_pca_given_versicolor = (W * X_given_versicolor_training')';
X_pca_given_virginica = (W * X_given_v... |
function testPairs = compareModel(testPairs,modelList,modelA,modelB,description)
getLoc = [find(strcmpi(modelList(:,2),modelA)),find(strcmpi(modelList(:,2),modelB))];
testPairs(end+1,:) = {modelA,modelB,description,getLoc}; |
function [t, ref, thh, thd, i, out] = plot_and_save(simulink_out, str_name, additional_data)
%PLOT_AND_SAVE_SCOPES accepts the variable "out"("ans") from simulink, a
%string for the name and additional variables to be saved (in a struct)(0 for no additional vars)
O = simulink_out;
t = O.thh_sc... |
function [K, F, M, dK, dF, dM, dF_dL] = Matrices(AC,Load,Ts,cNode,Xea,Yea,dcNode,dXea,dYea,n,Vf,dVf,Wf,dWf,DV,DP)
global Adjoint
nT = AC.Structure.nT;
yT = AC.Structure.yT;
nAirfoil = AC.Wing.Airfoils.nAirfoil;
yAirfoil = AC.Wing.Airfoils.yAirfoil;
nNode = AC.FEM.nNodea;
nDOF = AC.FEM.nDOF ;
nElm ... |
%% 1. Zero mean complex noise
% 1.1 Create synthetic data (random noise with zero mean)
rng(1)
data = randn(10,1) + randn(10,1)*i;
magData = abs(data);
measurements = magData;
%1.2 Define sigma and mu values for likelihood visualisation
sigmaValues = [0.1:0.01:1.1];
muValues = 0:0.01:2;
%1.3 Loop through possibil... |
function xdot = WilsonCowan(x,P)
% Set parameters
% Excitatory % Inhibitory
tauE = 3.2; tauI = 3.2 ;
cEE = 2.4 ; cIE = 2 ;
cEI = 2 ; cII = 0 ;
kE = 4 ; kI = 4 ;
thE = 1 ; thI = 1 ;
% Extract firing rates of E and I populations
E = x(1) ;
I = x(2) ;
% Make sigmoid fu... |
%% Load data and store zero-crossings of training set
frameSize = 0.1;
nCrossings = cell(1,2);
genre = 'kiki';
datasubset = 'train';
songs = loadkikibouba(genre,datasubset);
nCrossings{1} = cell2mat(computecrossings(songs,frameSize));
genre = 'bouba';
datasubset = 'train';
songs = loadkikibouba(genre,datasubset);
nC... |
%ucitavamo podatke
load('A.mat');
load('labels.mat');
A = full(A);
%radimo matricu B, koja sadrži A i 2 dodatna stupca, 1 predstavlja stvarne
%klastere, a drugi početnu particiju.
% [m, n] = size(A);
%
% for i = 1 : m
% A(i, :) = A(i, :) / norm(A(i, :));
% end
% A = [A labels];
%
% clusterSize = 1... |
% Develop Matlab scripts to generate the discrete-time sequences
% (i) Unit impulse x[n] = ?(n)
% (ii) Unit step x[n] = µ(n)
% (iii) Real exponential x[n] = exp[n]
% (iv) Complex exponential x[n] = exp[(5j)n].
% Plot all these sequences in the same figure.
% Develop a Matlab function for complex exponentia... |
%%
% Confronti tra ripetizioni
%clear variables
close all
figure (1)
hold on
titolo= 'Confronto ripetizioni punto 4 (pesante1 gesso)';
sgtitle(titolo)
% colori: #0072BD #D95319 #EDB120 #7E2F8E #77AC30 #7E2F8E
%confronto campioni di materiali diversi
subplot(3,1,1),hold on,
plot (f, 20*log10(PSD_Fav_pgram4_1), ... |
fprintf('ROCHJ v2.2 - matlab/octave postprocessing ');
clear
%close all
global level_set XPAUSE
global Zmin Zmax %- to be adjusted depending of [min,max] values of data
%- OCTAVE test %- Default is OCTAVE=0. Special commands for octave : (graphs, legends...)
OCTAVE = (exist ('OCTAVE_VERSION', 'builtin') > 0... |
function [xy_pairs, side_image_nm, n_of_particles] = ReadXYPairFromFile ()
% disp('*** ReadXYPairFromFile')
pwd = 'C:\Users\david\Box Sync\matlab\pair_correlation_function\';
filename = ['2015-10-18_new_grain_positions\' 'CMBE90_011_500n.000.drh.dat'];
path = [pwd filename];
side_image_nm = 500;
... |
function [fonrank, front]= NONDOM_SORT(pop)
%pop = [21,29,34,39,56;20,28,31,31,51;21,29,31,31,56;21,29,100,40,51;21,29,42,39,56];
shape = size(pop(:,1));
%fonrank = zeros(shape);
front = zeros(shape);
prey_no = length(pop(:,1));
dominates = zeros(prey_no,prey_no);
for i = 1:length(pop(:,1))
broadcast ... |
function []=plotNcorrPairResults(varargin)
%% function for plotting 2D-DIC results imported from Ncorr in step 2
% plotNcorrPairResults;
% plotNcorrPairResults(DIC2DpairResults);
%%
switch nargin
case 0
% ask user to load ncorr results for current camera pair
[FileName,PathName,~] = uigetfile('','... |
function[datos,var]=extraer_numero_de_un_string(datos)
%Busca de la cadena de texto hasta donde el caracter tiene el simbolo de
%"=" ya que guid manda en ese formato el string, y asi poder obtener el
%el valor numerico.
var = datos;
for i = 1:length(datos);
if datos(i) == '=';
var = datos(1:min(5,len... |
function [ gaugeValue ] = interpolateOutputStepResultToGaugePoint( obj, xg, yg, zg, outputStep )
Ng = numel( xg );
gaugeValue = zeros(Ng, obj.Nvar);
fresult = obj.accessOutputResultAtStepNum( outputStep ); %
for m = 1:obj.Nmesh
[ cellId, Vg ] = obj.meshUnion.accessGaugePointLocation( xg, yg, zg );
for n = 1:Ng
... |
x = [0, 1, 1.5, 3];
y = [1, 1, 15, 15];
x_ii = 0:0.1:3;
hold on
stem(x, y)
plot(x_ii,Lagrange(x, y, x_ii))
hold off
func1 = @(x) 10.72*x.^3 + (1-x) - 9.72*x;
func2 = @(x) 21.45*(1.5-x).^3 - 16.68*(x-1).^3 - 3.36*(1.5 - x) + 34.17*(x-1);
func3 = @(x) -5.56*(3-x).^3 + 22.51*(3-x) + 10*(x - 1.5);
hold on
stem(x, y)
plo... |
function [x fit exitflag output] = MR1 (y, w, E)
% Uses lsqlin to solve standard monotonic regression problem
% y is a vector of values - the data
% MR conducts monotonic regression on each column separately
% w is the weight matrix for the (lsqlin) fit: either a vector of positive
% numbers or a positive definite... |
clearvars
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% plot systematic ideal wave variations with 3DST and 2D+1
%
% Corwin Wright, c.wright@bath.ac.uk, 2020/10/18
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%... |
classdef Graph
% Graph class
properties
V = []; % vertices
E = []; % edges
end
properties (Dependent = true)
dim % number of dimensions
N % number of vertices
M % number of edges
A % adjacency matrix
end
methods
%% CONSTRUCTOR... |
% Author:Eduardo Alho
%Date:10/03/2017
%Uses k-means clustering for blockface segmentation
%root_dir: directory where images are
%sigma= standard deviation of gaussian distribution for gaussian blur
%filter, for blockface segmentation 5 is a good start (more blur with
%higher numbers)
%clusters: number of color cluste... |
%清除画布
clf;
%清除坐标轴
cla;
%关闭窗口
close all;
%清除所有原有变量
clear all;
%清除命令窗口的内容
clc;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%图像1
Image1=imread('data/1.jpg');
Image2=imread('data/2.jpg');
%RGB->HSV,double->double
Image10=rgb2hsv(Image1);
Image20=rgb2hsv(Image2);
%图像分量
Image11=Image10(:,:,1);
Image12=Image10(:... |
%% Preambule
mu=0.02;
sigma=0.2;
time=82/252;
yield=0;
Strike=12;
Start=11;
%% 1D Plots
ValueCall=[];
ValuePut=[];
Startvec=[];
resolution=0.01;
for i=1:1000,
Start=8+i*resolution;
[A,B]=blsprice(Start,Strike,mu,time,sigma,yield);
ValueCall(end+1)=A;
ValuePut(end+1)=B;
Startvec(end+1)=Start;
end
s... |
mu_a = [5 10];
mu_b = [10 15];
mu_c = [5 10];
mu_d = [15 10];
mu_e = [10 5];
[m_de, b_de, isVertical_de] = MED(mu_d, mu_e);
[m_ce, b_ce, isVertical_ce] = MED(mu_c, mu_e);
figure; hold on;
x1 = linspace(10,25);
z = m_de*x1 + b_de;
plot(x1,z);
x2 = linspace(-5,10);
z = m_ce*x2 + b_ce;
plot(x2,z);
% CD STUFF
plot([10 10... |
% rpteq Reporting Equations (rpteq Objects).
%
% Reporting equations (rpteq) objects are systems of equations evaluated
% successively (i.e. not simultaneously) equation by equation, period by
% period.
%
% There are three basic ways to create
% reporting equations objects:
%
% * in the [`!reporting_equations`](modell... |
clear
clc
x=[ 0 1 2 3 ]
y=[ -3 -2 4 0 ]
n=length(x)-1
%3. Cálculo por n Splines
%teremos 'n' splines cubicas, uma para cada intervalo, formando um sistema tridiagonal de 'n-1' equacoes para S (derivadas de segunda ordem)
a=[];b=[]; %zera memoria
[a b c d]=fSplineb(n,x,y) % Splines quadráticas ... |
function [c, ceq] = constraint(x)
c = x(1)^2+x(2)^2-2 ;
ceq = [];
end |
clear all;clc;close all;
load ts_cons_rand
%% with u_res
for i = 51:60%length(U_res)
u_res = U_res{i};
% TransSyst
ts_ref{i} = ArrayGener_parallel(M_X,M_U,tau,r,lmax,u_res);
disp('Done.')
%% Controller
disp('Compute winning set and controller...')
% ts_ref.add_progress_group([1,20],uint32... |
function yp = resamp(y, m)
padlen = length(y)*(m - 1);
zlen = ceil((length(y)+1)/2);
z = fft(y);
zp = [z(1:zlen) zeros(1, padlen) z(zlen+1:end)];
if ~mod(length(y), 2);
zp(zlen) = zp(zlen)/2; zp(zlen+padlen) = zp(zlen);
end
yp = real(ifft(zp))*m;
|
%
% Owner: Ali Jabir
% Email: syedalijabir@gmail.com
%
% Licensed under the Apache License, Version 2.0 (the "License");
% you may not use this file except in compliance with the License.
% You may obtain a copy of the License at
%
% http://www.apache.org/licenses/LICENSE-2.0
%
% Unless required by applic... |
function clsLoss = classConfidenceLoss(classPredCell, classTarget, boxMaskTarget)
% Binary cross-entropy loss for class confidence score.
% Copyright 2021 The MathWorks, Inc.
clsLoss = sum(cellfun(@(a,b,c) crossentropy(a.*c,b.*c,'TargetCategories','independent'),classPredCell,classTarget,boxMaskTarget(:,3)));
end |
function gradConf = GradientConf(Bx, By, maskSize)
%% Compute the gradient confidence r for all pixels (Eq.(2))
% INPUT
% Blur (matrix) the Burry image(gray)
% maskSize (scalar) the size of kernel(m by m) m is odd.
% OUTPUt
% gradConf (matrix) the gradient confidence r
% A... |
function [Mu, C, EigenVectors, EigenValues] = compute_pca(X)
%COMPUTE_PCA Step-by-step implementation of Principal Component Analysis
% In this function, the student should implement the Principal Component
% Algorithm
%
% input -----------------------------------------------------------------
%
% o X ... |
function x=Siedel(A,b,xbas,tol,max_it)
n=size(A,1);
x=xbas;
C=-A;
for i=1:n
C(i,i)=0;
end
for i=1:n
C(i,:)=C(i,:)/A(i,i);
end
for i=1:n
r(i)=b(i)/A(i,i);
end
i=1;
while(i<=max_it)
xold=x;
for j=1:n
x(j)=C(j,:)*x+r(j);
end
if abs(xold-x)<tol
disp('Gauss-Seidel method ');
... |
function [X_train, X_test, y_train, y_test] = sklearn_data_2clusters()
% Generate a data set containing two clusters.
%% PARAMETERS
n = 300;
test_size = 1/3;
%% GENERATE
y = randn(n,1)>0;
X = randn(n,2);
% two clusters
X(y,:) = bsxfun(@plus,X(y,:),[1 1]);
X(~y,:) = bsxfun(@plus,X(~y,:),[-1 -1]);
[X_train, X_test,... |
%%
%================================
%for fly song, perform spectrogram (window = 200ms)
song = small_song; %ideal filtered 100-900Hz
song = song./55; %gain of 55 on Brownlee amp
l = length(song);
N = [];
N1 = [];
N2 = [];
S1 = [];
F1 = [];
T1 = [];
Fs = 10000;
nwnd = 200; %20ms
nfft = 10000;
nwnd = w... |
function [t,x]=mab5(f,intervalo,x0,N)
h=(intervalo(2)-intervalo(1))/N;
t=intervalo(1):h:intervalo(2);
x(:,1) = x0(:);
% xi+2 = xi + 2hf(ti+1, xi+1)
% function [t,x]=meuler(f,intervalo,x0,N)
[~, x] = mrk4(f, [t(1), t(5)], x(:, 1), 4);
x=x.';
ev(:, 1) = f(t(1), x(:,1));
ev(:, 2) = f(t(2), x(:,2));
ev(:, 3) = f(t(3), x(... |
close all; clear; clc
% Load track and vehicle data
load('CircuitOfAmerica.mat');
load('VehicleDataAudiTTS.mat');
global mu g
mu = 0.95;
g = 9.81;
%% Fiala tire model table
dalpha = 0.0001;
diff_num = @(f,x,dx) (f(x+dx)-f(x-dx))/(2*dx);
% front tire
F_z_f = car.m*g*car.b/(car.a+car.b);
alpha_f_cr = atan(3*mu*F_z_f/... |
%------------------------------------
% Simulacao do TBS
%------------------------------------
clc
clear all
close all
NumberOfS = 2; %Numero de SPT(Signal Power of Two), ou s's, em Sum tan^-1 [a0j*2^-s0j + a1j*2^-s1j]
W = 3; %word-length de Theta
Rm = 3; %Numero máximo de interações CORDIC
TargetAngleBase = 2*pi/10... |
function [spec,wts,iwts] = invaudspec(aspectrum, sr, nfft, fbtype, minfreq, maxfreq, sumpower, bwidth)
%pspectrum = invaudspec(aspectrum, sr, nfft, fbtype, minfreq, maxfreq, sumpower, bwidth)
%
% Invert (as best we can) the effects of audspec()
%
% 2004-02-04 dpwe@ee.columbia.edu
if nargin < 2; sr = 16000; end
i... |
% ECE 310 HW #3 Plotting Help
w = [0:pi/4:2*pi];
y_d = 1 - ((.5*exp(-j*w)).^4);
d = 1-.5*exp(-j*w)
%Y_d = (1 - (.5*exp(-j*w)).^4)/(1-.5*exp(-j*w))
Y_d = y_d./d;
%%
figure(1)
%subplot(2,1,1);
plot(w,abs(Y_d));
%subplot(2,1,2);
%plot(w,phase(Y_d));
Mag = abs(Y_d)
%%
w = [-pi:2*pi/100:pi];
v1 = 14*sinc(14*(w+(pi/4))/pi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.