<< Chapter < Page | Chapter >> Page > |
distinct.m
function y = distinct(T)
determines and sorts the distinct
members of matrix
T .
function y = distinct(T)
% DISTINCT y = distinct(T) Disinct* members of T% Version of 5/7/96 Rev 4/20/97 for version 4&5.1, 5.2
% Determines distinct members of matrix T.% Members which differ by no more than 10^{-13}
% are considered identical. y is a row% vector of the distinct members.
TS = sort(T(:)');n = length(TS);
d = [1 abs(TS(2:n) - TS(1:n-1))>1e-13];y = TS(find(d));
freq.m sorts the distinct members of a matrix, counts the number of occurrences of each value, and calculates the cumulative relativefrequencies.
% FREQ file freq.m Frequencies of members of matrix
% Version of 5/7/96% Sorts the distinct members of a matrix, counts
% the number of occurrences of each value, and% calculates the cumulative relative frequencies.
T = input('Enter matrix to be counted ');[m,n] = size(T);[t,f] = csort(T,ones(m,n));p = cumsum(f)/(m*n);
disp(['The number of entries is ',num2str(m*n),])
disp(['The number of distinct entries is ',num2str(length(t)),])
disp(' ')dis = [t;f;p]';disp(' Values Count Cum Frac')
disp(dis)
dsum.m
function y = dsum(v,w)
determines and sorts the distinct
elements among the sums of pairs of elements of row vectors
v and
w .
function y = dsum(v,w)
% DSUM y = dsum(v,w) Distinct pair sums of elements% Version of 5/15/97
% y is a row vector of distinct% values among pair sums of elements
% of matrices v, w.% Uses m-function distinct
[a,b]= meshgrid(v,w);
t = a+b;y = distinct(t(:)');
rep.m
function y = rep(A,m,n)
replicates matrix
A ,
m times
vertically and
n times horizontally. Essentially the same as the function
repmat in
MATLAB version 5, released December, 1996.
function y = rep(A,m,n)
% REP y = rep(A,m,n) Replicates matrix A% Version of 4/21/96
% Replicates A,% m times vertically,
% n times horizontally% Essentially the same as repmat in version 5.1, 5.2
[r,c]= size(A);
R = [1:r]';
C = [1:c]';
v = R(:,ones(1,m));w = C(:,ones(1,n));
y = A(v,w);
elrep.m
function y = elrep(A,m,n)
replicates each element of
A ,
m times vertically and
n times horizontally.
function y = elrep(A,m,n)
% ELREP y = elrep(A,m,n) Replicates elements of A% Version of 4/21/96
% Replicates each element,% m times vertically,
% n times horizontally[r,c] = size(A);R = 1:r;
C = 1:c;v = R(ones(1,m),:);
w = C(ones(1,n),:);y = A(v,w);
kronf.m
function y = kronf(A,B)
determines the Kronecker product
of matrices
. Achieves the same result for full matrices as the MATLAB function
kron .
function y = kronf(A,B)
% KRONF y = kronf(A,B) Kronecker product% Version of 4/21/96
% Calculates Kronecker product of full matrices.% Uses m-functions elrep and rep
% Same result for full matrices as kron for version 5.1, 5.2[r,c] = size(B);[m,n] = size(A);y = elrep(A,r,c).*rep(B,m,n);
colcopy.m
function y = colcopy(v,n)
treats row or column vector
v as a column vector and makes a matrix with
n columns of
v .
function y = colcopy(v,n)
% COLCOPY y = colcopy(v,n) n columns of v% Version of 6/8/95 (Arguments reversed 5/7/96)
% v a row or column vector% Treats v as column vector
% and makes n copies% Procedure based on "Tony's trick"
[r,c]= size(v);
if r == 1v = v';
endy = v(:,ones(1,n));
Notification Switch
Would you like to follow the 'Applied probability' conversation and receive update notifications?