Answered
how to make hourly average
h0 = cumsum(ones((datenum(2010, 1, 1)-datenum(2005, 1, 1))*24,1)); d0 = datenum(2005,1,1,h0,0,0); % Let your date d2 = ...

13 years ago | 0

Answered
using testtype to check odd or even numbers
if rem(jj,2) == 1 % odd statements elseif rem(jj,2) == 0 % even statements end or if rem(jj,2) ...

13 years ago | 0

| accepted

Answered
How do I take the average of every n values in a vector?
x = randi(1000,399277,1); n = 1000; m = numel(x); out = nanmean(reshape( [x(:);nan(mod(-m,n),1)],n,[])); or ...

13 years ago | 8

Answered
Create a moving average
A - your data L = filter(ones(101,1)/101,1,[A(:) zeros(50,1)]); out = L(51:end);

13 years ago | 1

| accepted

Answered
if we enter n rows and m colums and gets the output of 2n rows and 2m columns
Please read about MATLAB functions: <http://www.mathworks.com/help/matlab/ref/ones.html |ones|> and <http://www.mathworks.com/h...

13 years ago | 0

| accepted

Answered
hello i have some doubts about using recursive method about making matrix into sub matrices and should be saved in a single array.
A= reshape(1:24,6,[])'; % your array s = size(A); m = [2 3]; % size of your block t = reshape(A,m(1)...

13 years ago | 0

Answered
using greater than or less than in 'switch' and 'case' expressions
use |if...elseif..else..end| if x > 5 disp ('x is greater than 5') elseif x < 5 disp ('x is less than 5')...

13 years ago | 1

| accepted

Answered
I need to remove every other 9 rows of a matrix
A = randi(100,57,5); % your data a = 19*ones(size(A,1)/19,1); A(bsxfun(@plus,cumsum(a) - a + 1,0:8),:) = [];

13 years ago | 2

Answered
How do I copy a 320x240 matrix into a 640x480 matrix and expand everything 200%?
B = kron(A,ones(2));

13 years ago | 1

| accepted

Answered
Extraction of portion of textfile
f = fopen('nameYourTextFile.txt'); c = textscan(f,'%s','delimiter','\n'); fclose(f); out = c{:}(find(strncmp(c{:},'...

13 years ago | 0

Answered
cfit object doesn't work with 'plot' or 'differentiate'
x = (0:.01:4)'; % y = -4 + 8./(1+exp(4.*(x - 2))) + .5*randn(numel(x),1); % your da...

13 years ago | 0

Answered
Delete rows with strings for a cell array
A = {'Cause' 'CSSR (%)' 'MO Attempts' 'MT Attempts' 'fghytresdfhjjiiuyt' [ 1] [ ...

13 years ago | 1

| accepted

Answered
Delete rows with NaN for a cell array
A - your cell array out = A(any(cellfun(@(x)any(~isnan(x)),A),2),:); ADD out = A(all(cellfun(@(x)any(~isnan(x)),A),...

13 years ago | 2

Answered
Polyval gives me a error
t1 = feval(g,0.001)

13 years ago | 1

| accepted

Answered
atan2 of successive point in an Array
out = atan2(A(2:end),A(1:end-1)); or for jj = numel(A)-1:-1:1 out(jj,1) = atan2(A(jj+1),A(jj)); end or ...

13 years ago | 0

Answered
How do i reconstruct a matrix???
a - your array a1 = a; n = unique(a(:,1)); for jj = 1:numel(n) if rem(n(jj),2) == 0 t = a1(:,1) == ...

13 years ago | 0

| accepted

Answered
How to impute missing values using mean for a table
t = ~isnan(a); a1 = a; a1(~t) = 0; s = sum(t); s(s == 0) = 1; out = sum(a1)./s; or as said Iain: o...

13 years ago | 1

Answered
Question about vectorizing a search function
[a,b] = ismember(ccoFaceMx(:,1),1:nPoints); [a1,c,c] = unique(b(a)); d = (1:numel(a))'; out = [num2cell(a1), accumarr...

13 years ago | 1

Answered
Finding unique rows in a matrix and summing their weights faster
A = [1 2 4 6 1 2 9 2 4 2 6 9]; [aa,cc,cc] = unique(A,'rows'); W = (1:size(A, 1))'; wA = accumarray...

13 years ago | 0

| accepted

Answered
How to calculate distance from one point base to multipoints and save it as a row?
AP_dist= sqrt(sum(bsxfun(@minus,MS_loc,AP_pos).^2,2)); OR for jj = size(MS_loc,1):-1:1 AP_dist(jj,1) = pdist([M...

13 years ago | 1

| accepted

Answered
How do i use regular expressions effectively for parsing my text?
try: pattern = '\<red(dy|dish)?\s' ADD pattern = '\<red(d)?(y|ish)?\>'

13 years ago | 0

| accepted

Answered
how to merge two matrices via one common column
[~,ii] = ismember(A(:,2),B(:,1)); out = [A, B(ii,2)];

13 years ago | 0

| accepted

Answered
Writing matrix for 2D plane of atoms
a = [-1 2 1]; n = 100; m = numel(a)-1; out = full(spdiags(ones(n,1)*[-1 2 1],-m:m,n,n));

13 years ago | 0

| accepted

Answered
finding the power of a number
x = 0.6543e+013 x*10^-ceil(log10(x))

13 years ago | 0

Answered
Simple question about functions
data1 = practicefcn(); x = data1.x;

13 years ago | 0

| accepted

Answered
how do I vectorize a loop with multi-dimensional arrays/ outer product
B1 = B(:,:,4); out = reshape(B1(:)*(0:N-1),[size(B1) N]);

13 years ago | 1

| accepted

Answered
Count the "areas" of zeros and the "areas" of ones in a vector?
a=[0 1 1 1 1 1 1 0 0 1 1 1 1 1 0 0 1 1 1 0 1 ]; lc = [true;diff(a(:))~=0]; x = a(lc); zerosareas = sum(~x...

13 years ago | 0

| accepted

Answered
randomly displaying a string from an array
out = X(randi(numel(X)));

13 years ago | 0

| accepted

Answered
How to find x,y matrix using for sintax
out = a(any(a,2),any(a));

13 years ago | 0

Answered
Timestamp Formatting (Datenum Limitation?)
datenum('01/01/13 03:12:45 PM','mm/dd/yy HH:MM:SS PM'); ADD datenum({'01/01/13 03:12:45 PM','01/02/13 06:12:45 AM'},'m...

13 years ago | 0

Load more