Answered
Error in matrix dimension and using a plus sign?
<http://en.wikipedia.org/wiki/Trapezoidal_Rule |Wikipedia|> about your problem: function M = mittpunkt(fun,a,b,n) h = (b...

13 years ago | 1

Answered
find a minimum in a 3d matrix
[v,loc] = min(P(:)); [ii,jj,k] = ind2sub(size(P),loc);

13 years ago | 10

| accepted

Answered
Round coefficients of symbols
syms M S X=[1.89545464564*S+0.00000085*M, 1.00000055*S-0.68129354234*M; 0.00000000345*S+0.00000346*M, 1.00004353*S+1.68129...

13 years ago | 3

Answered
Simple Question about Optimization of Nested IF-FOR loops
DoseCubeU = bsxfun(@times,100*SumDose/RX,SliceMaskUr==1); ADD s = SliceMaskUr(end:-1:1,end:-1:1); tt = cumsum(cumsu...

13 years ago | 0

Answered
How to create matrices of Symbolic Variables in an earlier version of Symbolic toolbox
2D symbolic array with size [7 x 5]: m = 7; n = 5; [ii,jj] = ndgrid(1:n,1:m); v = sprintf('x%d%d,',[ii(:),jj(:)]'); ...

13 years ago | 0

Answered
how to add bits in between the binary data
out = reshape(ones(251,1)*P(:)',1,[]); or out = kron(P(:)',ones(1,251));

13 years ago | 0

Answered
Find numbers within (n)
B = [ 267 267 391 391 391 267 267 267 308 308 308 308 ...

13 years ago | 0

Answered
Mean a matrix columnwise based on another logical matrix
b1 = bsxfun(@times,b,1:4); out = accumarray(b1(b),a(b),[],@mean); or [~,jj] = find(b); out = accumarray(jj,a(b),...

13 years ago | 2

Answered
How to Select a distinct subset of a CellArray
x = [1,1;1,2;1,3;2,1;2,2]; out = x(x(:,1) == 1,:);

13 years ago | 0

Answered
Create a structure name based on the string of a variable. Create fieldnames in this structure.
report_1 = cell2struct(num2cell([mean(1:4) std(1:4)]),{'a','b'},2);

13 years ago | 0

Answered
sum every 5 rows of a column, Is the part of code right
startdec2 = sum(reshape([startdec1;zeros(mod(-numel(startdec1),5),1)],5,[])).'; ADD startdec1 = rand(42,1) < .7; b ...

13 years ago | 0

| accepted

Answered
Convert vector of cells to variables
use |dataset array| Text={'Temp', 'Humidity', 'Age'} num=[20 0.8 2; 22 0.85 2.1; 23 0.9 2.2] d = mat2dataset(nu...

13 years ago | 0

Answered
find out the percentage of pixels having value 1
a = randi([0 1],497,597); ones_frac = conv2(a,ones(3),'valid')/9*100; or if you have |Image Processing Toolbox| one...

13 years ago | 0

Answered
Piecewise Cubic Hermite Interpolating Polynomial (PCHIP) for given data and then finding area
x = [5.8808 6.5137 7.1828 7.8953]; y = [31.2472 33.9977 36.7661 39.3567]; pch = pchip(x,y); out = fnval(fnint...

13 years ago | 0

| accepted

Answered
How to sequentially add rows to a matrix according to certain contingencies?
[ii,jj] = ndgrid(1:3); a = [ii(:),jj(:)]; a1 = a(randperm(length(a)),:); [b2 b2] = unique(sort(a1,2),'rows'); out ...

13 years ago | 0

| accepted

Answered
What does this line of code mean in non-code speak?
~rem(year,4)&rem(year,100)|~rem(year,400)

13 years ago | 0

Answered
Make true all the false rows of a column of a matrix which are in between the first true and the last true row
b = cumsum(a)&flipud(cumsum(flipud(a)))

13 years ago | 2

| accepted

Answered
Circshift the columns of an array with different shiftsize withou using for loop
[m,n] = size(a); b = rem(shiftindex-1,m)+1; c = rem(bsxfun(@plus,m + 1 - b - m*(b == 0),(0:m-1)')-1,m)+1; out = a(bsx...

13 years ago | 3

Answered
Finding numbers over a value in a matrix/array
A = rand(20,10); A(A < .3) = -A(A < .3); % your array out = nnz(A < 0);

13 years ago | 0

Answered
Simple Question about Optimization of a FOR loop
A(1,:) = B((0:size(A,2)-1)*3+1);

13 years ago | 0

Answered
How can I find the maximum value in a matrix?
A = randi(100,7,6); % your matrix v = max(A(:)); % value [ii,jj] = find(A == v); % row and column number

13 years ago | 3

| accepted

Answered
How to remove zero values from vector?
q = [0 0 0 2 4 10 9 5 0 0 0 8 9]; out = [q(1:find(q~=0,1,'first')-1) q(q~=0)];

13 years ago | 0

| accepted

Answered
Simple Question about Optimization of Nested FOR loops
B = zeros(X,Y,Y); B(:,1,:) = permute(C.*(A == 1),[1,3,2]); B = B(:);

13 years ago | 0

Answered
get specific elements from all non-empty cells
A = cell(size(A)); ii = ~cellfun('isempty',C); A(ii) = cellfun(@(x)x(2),C(ii),'un',0); or use loop |for..end| ...

13 years ago | 1

| accepted

Answered
Indexing (or maybe cellfun?) problem - appending numbers from a vector to rows/cols of cell array
a(1,:) = cellfun(@(x,y)[x,y],a(1,:),b,'un',0)

13 years ago | 0

Answered
Running a summation for a loop for different values of N.
N = [5 20 100] b = 2; c = 4; f = arrayfun(@(x)[(1:x)',reshape(func((1:x)',b,c,x),[],1)],N,'un',0); plot(f{:});...

13 years ago | 0

Answered
How to improve the code for vector calculation
B = rand(12,3); P = rand(1,12); Ba = permute(reshape(B,3,4,[]),[1 3 2]); Pn = reshape(P,3,1,[]); Pa = bsxfun(@...

13 years ago | 1

Answered
Keep only elements that appear multiple times
[a,b] = histc(A(:),unique(A)); A(a(b) < 3) = 0;

13 years ago | 1

Answered
Logical Indexing with zero and one. Getting only the change from 0 to 1 and from 1 to 0.
B = [0;diff(A)==1] + flipud([0;diff(A(end:-1:1))==1]); B = [false;diff(A)==1] | flipud([false;diff(A(end:-1:1))==1]); % log...

13 years ago | 0

Answered
how to remove NaN
M = {3 [4 5] nan;[2 4] 'dfgh' [7 8 3]}; ii = ~cellfun(@(x)all(isnan(x(:))),z(:,3)); out = M(ii,:);

13 years ago | 0

Load more