Answered
To set value based on condition in a matrix
m=13; % [m,n] - size of our matrix n=7; i1 = 5; x = 1; B = repmat(x*eye(n),2*ceil(m/n),1); Bout = B(i1:i1+m...

14 years ago | 1

Answered
plotting data extending one year
try this is code t = datenum('2008-04-17 02:00'):datenum('2009-11-24 12:27'); data = randi(150,numel(t),1); DOY =...

14 years ago | 1

| accepted

Answered
Matrix Resize Rows and Cols
A - your matrix (48x52) Anew = zeros(48,48); % new matrix with size 48x48 s = size(A); for jj = 1:s(1) Anew(jj...

14 years ago | 1

| accepted

Answered
how to calculate the maximum of different parts of a vector without using a for loop?
try this is code for condition: numel(H) == sum(s) maxH = cellfun(@max,mat2cell(H(:),s(:),1)); OR idx = zeros(s...

14 years ago | 1

Answered
How to create the following cell array with the following pattern quickly
m = {'s' 'o' 'd' 'p' 'x' '+' '*' '>'}; idx = hankel(1:numel(m),[numel(m) 1:numel(m)-1]); marker = m...

14 years ago | 1

| accepted

Answered
split a vecor into several parts (of different sizes) to later fill a matrix.
try this is code V = 10:10:140; % eg s =[3 6 5]; b = cumsum(s) - s + 1; i0 = bsxfun(@plus,b,(0:max(diff...

14 years ago | 1

Solved


Too mean-spirited
Find the mean of each consecutive pair of numbers in the input row vector. For example, x=[1 2 3] ----> y = [1.5 2.5] x=[1...

14 years ago

Solved


Interpolator
You have a two vectors, a and b. They are monotonic and the same length. Given a value, va, where va is between a(1) and a(end...

14 years ago

Solved


Unique - Very Very Large Numbers
Given a vector column, with some very large numbers, create the ascending sort and unique vector. *Input:* A (column vector)...

14 years ago

Answered
Sorting a Cell Array based in multiple dimenssion
B = { 'YPL-320' 'SMITH' 'Male' 38 'GLI-532' 'JOHNSON' 'Male' 43 'PNI-258' 'WILL...

14 years ago | 1

Solved


intersection of matrices
Given two matrices filled with ones and zeros, determine if they share a common row, column entry. These matrices are of identi...

14 years ago

Answered
Error in resizing 3d image
try this code A = randi(255,89,300,3,'uint8'); % eg first image B = randi(255,100,200,3,'uint8'); % eg second image ...

14 years ago | 1

Answered
How to sort the elements of a matrix in a random order
abc = [A,B,C] [~,idx] = sort(rand(size(abc))) out = abc(sub2ind(size(abc),idx,ones(size(abc,1),1)*(1:size(abc,2))));

14 years ago | 0

Answered
How to group elements of an array
try this is code, let A - your array with size 1500 x 2. k = find(abs(A(:,2) - 100) < eps(100)); [val,idx0] = min(A(k,1)...

14 years ago | 0

| accepted

Answered
Simple Looping + Sum Question
out = sum(reshape([sum(X(:,2:end),2);zeros(mod(-size(X,1),3),1)],3,[]),2);

14 years ago | 0

Answered
calculating hourly means of a matrix
other variant [c,c,c] = unique(time(:,1:4),'rows'); s{2} = kron((1:size(data,2))',ones(size(data,1),1)); s{1} = kron(...

14 years ago | 1

Answered
Fetching data from another column
[~,~,c] = unique(A(2:end,1)); gene = cellfun(@(x,y)[A(1,:);x;A([false,y],:)],num2cell(B(2:end,:),2),num2cell(bsxfun(@lt,c,c...

14 years ago | 0

| accepted

Answered
Combining data from other variable
P={ '' 'c1' 'c2' 'c3' 'Par1' 'PSO' 'SPSO' 'MPSO' 'Par2' 'SPSO' 'PSO' 'MPSO' 'Par3' ...

14 years ago | 0

| accepted

Answered
Grouping the pixel having same values
I =[83 81 81 84 85 84 82 82 84 81 83 83 81 81 83 81 81 83 83 82 80 81 83 80 8...

14 years ago | 0

| accepted

Answered
Calculating average over a year time
Power_year_average = trapz(Time_vector,Power_vector)/Time_vector(end);

14 years ago | 0

| accepted

Solved


Find the repeating decimal pattern!
Write a function that takes one double input value and returns only the repeating decimal, if any, as a string. Only decimals f...

14 years ago

Answered
is there a jump of 2 months?
[m,m] = datevec(A,'dd/mm/yyyy'); test = [0;mod(diff(m),12)] == 2;

14 years ago | 0

Answered
Populate structure array efficiently
S = struct('A',num2cell(A))

14 years ago | 2

| accepted

Answered
File and array manipulation.
Consider the matrices of the same size as the matrix |a|. s = size(a); k = whos; n = find(strcmp({k.class},'double'))...

14 years ago | 0

Answered
To Run A For-Loop
Please try code: fx = 2:2:2^5; fy = 2; a=128; b=128; [x,y] = meshgrid(linspace(-1,1,128)); circ=sqrt(x.^2+y....

14 years ago | 0

| accepted

Answered
How to find a value in a list?
z = [... 15 4 12 5 7 2 22 23 21 18 11 10 10 8 14 ...

14 years ago | 0

Answered
addition of elements in a matrix
Can so? A = randi(30,3,20); B = sum(reshape(A,size(A,1),4,[]),3); OR B2 = squeeze(sum(reshape(A,size(A,1),5,[]),...

14 years ago | 0

| accepted

Answered
problem with repeating index values
a = [0 0 0 0]; Index=[1 1 2 2 2]; s = regionprops(Index,'Area'); a(unique(Index)) = [s.Area];

14 years ago | 0

Answered
How many zeros do I have before a specific sting variable?
yourzeros = find(cellfun(@ischar,A),1,'first')-1;

14 years ago | 0

| accepted

Answered
Call matrix for multiplication
% 1. Your matrices (p1 .. p12): for j1 = 1:12 eval(['p',num2str(j1),' = randi(10,3,4)']); end % 2. Solution: ...

14 years ago | 0

Load more