Answered
random
x = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20]; ...

14 years ago | 0

| accepted

Answered
calculating the difference (in days) between successive dates
dd={'2-11-2008' '30-11-2008' '28-12-2008' '25-01-2009' '22-02-2009' '22-03-2009' '19-04-2009' '17-05-2009' ...

14 years ago | 0

| accepted

Answered
Matrix differentiation
syms a b c t M=[cos(a)*sin(b)*cos(c) sin(a)*sin(b)*sin(c) cos(a)^2*sin(b)^2*cos(c)]; k = regexprep(char(M),{'\(a\)','\(b...

14 years ago | 1

| accepted

Answered
How to get elements from large matrix
out = A(:,[1 7 9])

14 years ago | 2

| accepted

Answered
Sorting cell array of strings wrt. a character
k = cell2mat(cellfun(@(x)find(~cellfun('isempty',regexp(SM,x))),{'s' 'o'},'un',0)) out = SM([k setdiff(1:numel(SM),k)])

14 years ago | 0

Answered
solve command
[x,y] = meshgrid(-3:1:3); pqr = reshape(bsxfun(@plus,[-1.5;-.5;0]*pi,(1:10)*0.0173*5),3,1,[]); abc = cat(2,cos(pqr),si...

14 years ago | 0

Answered
matlab default directory
userpath('C:\Users\overlook\Documents')

14 years ago | 0

Answered
Finding corresponding rows in two matrices
[i1,i1] = ismember(desc1(5,:),desc2,'rows')

14 years ago | 0

| accepted

Answered
Partition function in Matlab - is there something missing in my code?
Sq = @(x,q)sum(abs(diff(x)).^q) eg Sq(Xt,5) EDIT Sq = @(x,q)sum(bsxfun(@power,abs(diff(x(:))),q(:)')); eg ...

14 years ago | 0

| accepted

Answered
Vary numbers i a textline
for jj = 1:n z(jj,:) = eval(['TC_Front_',num2str(jj),'.signals.values']); end

14 years ago | 0

| accepted

Answered
Compare value in one column and replace string in another column
x = cellfun(@str2num,M{5}); M{3}(x <= 2000 | x >= 40000) = {'miss'};

14 years ago | 0

Answered
finding unique string variables from a column vector
[data,text,alld] = xlsread('A.xlsx'); mdata1 = alld(:,5); t = cellfun(@(x)isnumeric(x),mdata1); mdata1(t) = cellfun(@...

14 years ago | 0

| accepted

Answered
Newbie: How to find and delete the min element of a matrix??
M= [ 2 7 9 ; 8 1 6 ; 8 5 7 ]; out = M(~any(min(M(:)) == M,2),:) OR [~,ii] = min(M(:)); [i1, ~] = ind2sub(s...

14 years ago | 0

| accepted

Answered
need to optimise my code
See nice Teja' <http://www.mathworks.com/matlabcentral/answers/38829-about-nested-for-loop solution>: A = sum(arrayfun(@(ii...

14 years ago | 0

Answered
loading an m.file with a series of matrices
better using cell arrays ( |C| ) for submission matrices d = who; d2 = strcat(d(strncmp(d,'Section',7)),','); C = ev...

14 years ago | 0

Answered
Geometric mean for a specific time intervals
data = [(1:130)', randi(100,130,1)]; out = accumarray(ceil(data(:,1)/60),data(:,2),[],@geomean,NaN);

14 years ago | 0

| accepted

Answered
use part of file name
fls = dir('AAA*.dat') fn = {fls.name} c = regexp(fn, '\d*', 'match' ) out = str2double(cat(1,c{:}))

14 years ago | 0

Answered
Cut an area in the image
use function |imcrop| from |Image Processing Toolbox|

14 years ago | 0

Answered
Function using for loop
x = unifrnd(3,36,20,1); [state2,state2 ] = histc(x,[-inf,5:5:30] + eps(100)); *or* k = [-30:5:-5 inf] [j1,j1] = ...

14 years ago | 0

Answered
calculating a few elements of a table, using a different equation
a = 49:52 b = 81:82 ii = fullfact([numel(b) numel(a)]) for jj = 1:size(ii,1) element(a(ii(jj,2)),b(ii(jj,1))) ...

14 years ago | 0

| accepted

Answered
Copy elements from one matrix to another under a condition
out = B.*A

14 years ago | 1

| accepted

Answered
put smaller matrix in bigger matrix
eg: Q = randi(456,10,15); row=[1 2 5 4 3 6]; column=[5 7 3 4 8 14]; P = Q(sub2ind(size(Q),row,column)); *EDIT...

14 years ago | 1

| accepted

Answered
combine multiple text files into one text file with a loop
k = arrayfun(@(x)dlmread([num2str(x),'.txt']),1:3,'un',0) out = cat(1,k{:}) dlmwrite('4.txt',out,'delimiter', ' ')

14 years ago | 0

Answered
what is the syntax to add noise in data set
may be using |data(:)|? eg rand_class_data = randsample(data(:),round(numel(data)*10/100))

14 years ago | 0

Answered
To form two cell arrays of same characters of same length and concatenate them
z = {'genuine';'forgery'}; out = z(kron([1;2],ones(70,1))); or out = z(reshape(repmat(1:2,70,1),[],1)); etc.

14 years ago | 0

Answered
HAMMING DISTANCE IN ONE ARRAY
eg: data = [1:19;randi([15 27],6,1),randi([0 1],6,18)]; [n,m] = size(data); num = data(2:end,2:end)*(2.^(m-2:-1:0...

14 years ago | 0

Answered
Working with binary and hex data
eg h = {'4BC1' '2452' '62AC'}; out = dec2bin(hex2dec(h))-'0';

14 years ago | 0

| accepted

Answered
link between two codes
? (eg) [a b c] = filewithcode1(x,y); out = filewithcode2(a, b, c);

14 years ago | 0

| accepted

Answered
solving logic , array and condition
on first code value =[... 2.2034000000000 5.9016000000000 24.0833000000000 25.1000000000000 10.3115000000000...

14 years ago | 0

Answered
Connected graph given adjacency matrix
try <http://www.mathworks.com/matlabcentral/fileexchange/4266-grtheory-graph-theory-toolbox grTheory> - Graph Theory Toolbox by...

14 years ago | 0

Load more