Answered
Index through datestring, selecting whole hours
Z = {'02-10-2014 20:30' [10934] '02-10-2014 21:00' [10195] '02-10-2014 21:30' [ 9388] '02-10-201...

12 years ago | 0

Answered
how to find patterns in an array
n = 5; idxv = find(conv2(double(diff(A) == 0),ones(n-1,1),'same') == n-1); idxv = idxv - 1; idxh = find(conv2...

12 years ago | 0

Answered
Integration numerical with variable limits
in your case: out = integral2(fxy,ymin,ymax,xmin,xmax);

12 years ago | 0

Answered
How to value value NaN in a 2d matrix?
please use |scatteredInterpolant|, example: a = randi([6 10],30,20); a(randperm(numel(a),20)) = nan; % a - your 2d array...

12 years ago | 0

| accepted

Answered
Decimal to Binary Vector
You should install |Data Acquisition Toolbox|, but have variant without |Data Acquisition Toolbox|. (idea by Jan Simon): [...

12 years ago | 2

Answered
how to value nan number in a vector? and how to do the same calc in a 2d matrix?
Let |X| your array with NaN's ii = ~isnan(X); i0 = reshape(1:numel(X),size(X)); Xout = interp1(i0(ii),X(ii),i0);

12 years ago | 0

| accepted

Answered
Fast sampling every other element in a matrix
M2 = M(1:2:end,1:2:end);

12 years ago | 2

| accepted

Answered
Subscripting into an empty matrix is not supported using For Loop and if Statement
All work. km=31416; x = rand(km,1); UPDN=zeros(size(x)); for k=1:km-2; if x(k+2)>=x(k); UPDN(k)=...

12 years ago | 0

Answered
How can I subtract columns for each row by using a for loop
X = [1.011 1.004 1.054 1.008 0.998 1.042 0.984 0.988 1.024 1.026 1.006 1.016 1.000 0.996 0.977...

12 years ago | 0

Answered
saving the output arrays in for loop
one way cd G:\Master_Students\Iman\UIUC\PNGImages\TrainImages n = dir('pos-*.PNG'); name1 = {n.name}; nn = numel(n...

12 years ago | 0

Answered
Average of Row Elements in a Multideminsional Array
one way A2 = cellfun(@(x)x(:,2),A,'un',0); B = mean([A2{:}]',2); other way A3 = cat(A,3); B = mean(A3(:,2,:),...

12 years ago | 1

| accepted

Answered
cell array or matrix for complex subtraction calculation
s = size(B); s2 = numel(A); k = ceil(s(1)/s2); out = [B;nan(mod(-s(1),s2),s(2))] - kron(ones(k,s(2)),A); % or out =...

12 years ago | 0

| accepted

Answered
How to convert matrix data from nc file to vector lon lat?
la0=ncread('yourncfile','latitude'); lo0=ncread('yourncfile','longitude'); d = ncread('yourncfile','DEN'); [la,lo]=nd...

12 years ago | 1

| accepted

Answered
How to sum/group values in a matrix based on their index values in first column?!
[a,~,c] = unique(X(:,1)); out = [a, accumarray(c,X(:,2))];

12 years ago | 13

| accepted

Answered
How to select non-sequential values in an array?
out = yourvector(1:4:end);

12 years ago | 0

| accepted

Answered
build m x m matrix
F = [-3 2 -3]; A=[5 -3]; C=[-3 4]; out = full(spdiags(ones(5,1)*F,-1:1,5,5)); out(1:2) = A; out(end-1:end) =...

12 years ago | 0

Answered
Creating new vector and using IF correct or loop?
v = [-inf,.5,1.5,inf]; [~,ii] = histc(position,v); m = [2 8 15]'; % example as m = [m1,m2,m3]; force = m(ii).*positio...

12 years ago | 0

Answered
convert to monthly mean (arrange data)
f=fopen('input.txt'); c = textscan(f,repmat('%f ',1,33),... 'EmptyValue',nan,'HeaderLines',1,'...

12 years ago | 0

| accepted

Answered
Newton's Method for nonlinear system vector operation.
function x = newtonf(x,finalstep) function out = F(x) out = [x(1).^2-x(2).^2+2*x(2); 2*x(...

12 years ago | 1

Answered
Subscripting into an empty matrix is not supported
x = x(:); UPDN = [x(2:end);[1;1]] >= [x(1:end-2);[0;0]];

12 years ago | 0

| accepted

Answered
For Loop using two variables and plotting
g = @(t,a)exp(-2*t).*cos(4*pi*t).*(t>=0)*exp(-a); t= (0:0.01:4)'; a=(1:2:7); y = bsxfun(g,t,a); figure; p...

12 years ago | 1

| accepted

Answered
How to take monthly of time series using loop I am having data form each month( having 30/31) data values
load yourdata.mat [ym,~,c] = unique(a(:,1:2),'rows'); s = size(a)-[0,3]; ii = repmat(c,s(2),1); jj = repmat(1:s(2)...

12 years ago | 0

Answered
Question about vector angular separation
U1 = [4 1 1; 1 1 0;2 1 1]; %your vectors U1norm = sqrt(sum(U1.^2,2)); U1e = bsxfun(@rdivide,U1,U1norm); v = bsxfun(@m...

12 years ago | 0

Answered
matrix with different randperm rows
[~, out] = sort(rand(M,N),2);

12 years ago | 5

| accepted

Answered
Calculating within-month standard deviation from daily return data
[Y,M] = datevec(data(:,1)); [a,~,c] = unique([Y,M],'rows'); out = [a, accumarray(c,data(:,2),[],@(x)std(x))];

12 years ago | 1

| accepted

Answered
How to covert a vector of lower triangular matrix factors back to the original matrix?
p = [ 1 2 2 3 5 3 4 9 8 4]; a = triu(ones(4)); a(a > 0) = p; out = (a + a')./(eye(4)+1);

12 years ago | 5

| accepted

Answered
store values in array in nested for loop
[r,c] = min(squeeze(sqrt(... sum(bsxfun(@minus,r2(1:5,:),permute(r1(1:2,5:end),[3 2 1])).^2,2))));

12 years ago | 0

Answered
addition of two matrix's with constraints
out = W.*cost; [ii,jj] = find(W > 0); ij = sortrows([ii,jj]); jj = sub2ind(size(W),ij(1,1),ij(1,2)); out(jj) = out...

12 years ago | 0

| accepted

Answered
counting number of times a values appears in file
a = [1, 2, 3, 4, 2, 1, 6, 4]'; a1 = unique(a); out = [a1 histc(a,a1)];

12 years ago | 0

Answered
taking special average of numbers
ab = randi(100,2,12); % here ab - your array ab2 = permute(reshape(ab,2,3,[]),[2 3 1]); ab(3,3:3:end) = dot(ab2(:,:,1),a...

12 years ago | 0

| accepted

Load more