Answered
to calculate minimum or maximum value of dataset
x_s = sortrows(x_train,[5,1]); c = accumarray(x_s(:,5),x_s(:,1),[],@(x){x([1,end])}); out = cat(2,c{:}); or c = ...

13 years ago | 0

Answered
Simple question on using and specifying equations
>> y = @(x)3*x+5; >> y(10) ans = 35

13 years ago | 0

Answered
Find a series of consecutive numbers in a vector
a = [34 35 36 78 79 80 81 82 84 85 86 102 103 104 105 106 107 201 202 203 204] n = 6 % number consecutive numbers k =...

13 years ago | 0

Answered
Separating values in cell arrays
a = arrayfun(@(x)randi(20,1,randi([2 4])),1:5,'un',0); % Let your data n = cellfun('length',a); x = zeros(sum(n),2);...

13 years ago | 0

Answered
How to sort an array and divide it to n parts depending of the values in it
m = dlmread('pathtovalidx.txt'); idx = cumsum([true;diff(m(:,1)) < 0]); a = unique(histc(idx,1:idx(end))); if numel(a...

13 years ago | 0

Answered
Delete only consecutive repeated string entries from a dataset in matlab
C ={ 'time' 'pitch' 'notation' 2.5725 329.63 'GM' 2.5800 329.63 'GM' 2.5900 311.13 'MM' 2.6000 570.4...

13 years ago | 0

| accepted

Answered
How to create a specific matrix from a regular matrix
[m,n] = size(A); B = ones(m+n-1,n); p = tril(B) & rot90( tril(B),2); B = B - 1; B(p) = A;

13 years ago | 0

Answered
Combining two strings to a common string
Variables = {'var1', 'var2', 'var3'}; Sectors = {'sec1', 'sec2'}; ii = fullfact([3 2]); out = strcat(Variables(ii...

13 years ago | 1

Answered
How can I extract the numbers from this string
str = 'JY CME JAPANESE YEN FUTURES SEP13 10157 10315 10149 ---- 10301 +162 162704 10139 77441 171982 DEC13 10'; ns = st...

13 years ago | 0

Answered
How can i find the position of same elements in matlab......
[a,b1] = unique(x,'first'); [a,b2] = unique(x,'last'); result = [a(:),b1,b2]; or ii = [find([true;diff(x(:))~=0]...

13 years ago | 0

| accepted

Answered
How can I expand a matrix by replacing its elements?
q = num2cell(eye(5),2); out = cell2mat(q(s+1)); or p=5; a=0:p-1; s = rem(a'*a,p) + 1; ii = bsxfun(@plus,s,...

13 years ago | 1

Answered
Creating pairs of vector elements
a = (1:9)'; b = a; c = a; [ii,jj,k] = ndgrid(a,b,c); out = [ii(:),jj(:),k(:)];

13 years ago | 0

Answered
Concatenate Aphabets and numbers
az = cellstr(('a':'z')'); n = numel(az); [ii,jj] = ndgrid(1:n); a1 = [az;strcat(az(jj(:)),az(ii(:)))]; out = s...

13 years ago | 0

Answered
Convert a 3-d matrix to a 2-d matrix
val(:,:,1) =[ 1 3 8 6 4 8 3 1 6]; val(:,:,2) =[ 4 10 6 9 9 4 6 ...

13 years ago | 0

| accepted

Answered
functions for finding values
Use |Curve Fitting Toolbox| a=5; w=-a:a/1000:a; F=2*sin(a*w)./w; % w_int=-5:0.01:5; w_int(abs(w_int) < e...

13 years ago | 0

| accepted

Answered
Numerical integration in Matlab
Try: f2_int = @(y)arrayfun(@(x)f_int(x),y); out = integral(f2_int,a,b); % here a and b - double

13 years ago | 1

Answered
Help sifting through data in a 2D matrix
Let |d| - your data. [a1,i1,i1] = unique(d(:,1:3),'rows'); i2 = [true;diff(rem(d(:,4),30)) < 0]; out = [a1, accumarra...

13 years ago | 0

Answered
extracting subsequences of binary string
N = 20; n = 4; A = hankel(1:N-n+1,N-n+1:N); k = 0:n-1; idx = []; for ii = 1:size(A,1) p = A(ii,:); ...

13 years ago | 0

| accepted

Answered
Looping through data and finding maximum value in each bin
ds = [... 10 5 1 10 6 2 11 3 2 11 7 1 11 4 1 ]; d1 = s...

13 years ago | 0

| accepted

Answered
Find maximum number of consecutive negative values
A = randi([-6,3],20,15); % Let it your array t = A < 0; s = size(t); tt = cumsum(diff([false(1,s(2));t]) == 1...

13 years ago | 0

| accepted

Answered
maximizing efficiency in simple commands
ones(4,1)*x kron(ones(4,1),x)

13 years ago | 0

Answered
How to generate N number of loops
I = {'AUU','AUC','AUA'}; H = {'CAU','CAC'}; Q = {'CAA','CAG'}; A = {I,H,Q}; A = A(:)'; n = cellfun('length'...

13 years ago | 0

| accepted

Answered
Decompose a matrix into smaller matrices by the date
DD = datevec(C(:,1),'dd.mm.yyyy HH:MM:SS') [a1,i1,i1] = unique(DD(:,1)); [a2,i2,i2] = unique(DD(:,2)); T = accumarray...

13 years ago | 1

Answered
Appending vectors in a loop
Data2 = [... 4 0.0119 5 0.0119 6 0.0143 7 0.0143 ...

13 years ago | 0

Answered
In a logical array index the area with the most TRUE values
t=[0 1 0 0 0 0 1 1 0 0 1 1 1 1 1 1 1 1 1 1 0 1 0 0 0 1 0]; ii = 3; out = cumsum([false;diff(t(:))==1]) == 3 & t(:); ...

13 years ago | 2

| accepted

Answered
Find cases of vectors-patterns in an array
t=[0 0 0 0 0 0 -1 1 1 1 1 1 1 -1 -1 -1 1 0 0 0 0]; t1 = t(:).' == -1; ii = [strfind(t1,[0 1]);strfind(t1,[1 0])+1].'; ...

13 years ago | 1

| accepted

Answered
Unique function problem with fzero
y=@(x)(x.^5-15*x.^4+85*x.^3-225*x.^2+274*x-120); x00 = [0 5]; % your choice n = 300; % your choice xx = linspace(...

13 years ago | 0

Answered
How to save different matrices in a loop and then using them in another loop of the same program?
A = cell(30,1); for jj = 1:30 % create your matrices A{jj} = randi(20,randi(5),randi([2 5])); % end

13 years ago | 0

Answered
Storing results from a for loop into a cell array vector
C = {'TGC','TGT'}; D = {'ATA','ATC','ATT'}; [jj,ii] = ndgrid(1:numel(D),1:numel(C)); out = strcat(C(ii(:)),D(jj(:...

13 years ago | 1

| accepted

Answered
Average of irregular range of data
tresh = 2; % Let greate than two days f = fopen('PathAndNameYourdata.txt');%'E:\wtdy2.txt' c = textscan(f,'%s %s %f'...

13 years ago | 0

Load more