Answered
Creating Matrix with nested loop values
[a,~,c] = unique(zeit(:,1:2),'rows'); xm = [a, accumarray(c,zeit(:,3),[],@mean)];

10 years ago | 1

| accepted

Answered
How to use variables in a matrix?
Qc = [176.7308, 2.7786, 0; 2.7786, 11.3413, 0; 0, 0, 4.1991]; func1 = @(h)sum(Qc(:)*diff(h*(-2:2)),2)...

10 years ago | 1

Answered
how to print all of output value from "for loping" function ?
function f=coba1(a) f = zeros(a,1); for jj=1:a f(jj)=jj; end or f = (1:a).';

10 years ago | 0

| accepted

Answered
Using data from cell arrays
value_PCA = cat(1,All{:});

10 years ago | 0

Answered
separating data into rows and colums
f= fopen('d20160413.txt'); c = textscan(f,'%s','delimiter','\n'); fclose(f) c = c{:}; [~,~,~,v] = regexp(c,'...

10 years ago | 0

| accepted

Answered
How to add value at end of row in a matrix
R=[2 4 5 2] C=[1 3 6 7] [b,ii] = histc(R(:),unique(R)); out = zeros(max(R),max(b)); for jj = 1:numel(b) ...

10 years ago | 1

Answered
Adding elements with specific distance in a matrix
t =[1 2 3 3 1 2 2 1 3 3 2 1 1 3 2 2 3 1]; s = size(t); M = reshape(t,s(1),3...

10 years ago | 1

Answered
2D Convolution algorithm error vs conv2 function
a =reshape(1:12,4,[]); b = reshape(1:8,2,[]); without |conv2| [m,n] = size(a); [m1,n1] = size(b); mn = [m,n] ...

10 years ago | 0

Answered
How does one count the characters in an array?
If your |Value| is numeric type, then: out = floor(log10(Value)+1); if |Value| is char type then: out = numel(...

10 years ago | 0

Answered
I want to sum specific elements in an a 2D matrix
a =[4 3 6 8 1 10 5 2 9 1 10 3 9 4 2 5 7 6 9 5 1 7 8 10 3 4 2]; n = 3; out = sum(reshape(a(:,n+1:end),n,n,[]),3...

10 years ago | 4

Answered
find result from multiple if and range value
x =[ 0 7.0000 0.0690 6.5000 0.1380 6.0000 0.2060 5.5000 0.2750 5.0000 0....

10 years ago | 0

Answered
Find the summation of the outer elements of a rectangular matrix
a=[2 -3 1 0;5 7 1 -4;9 -6 0 2] t = true(size(a)) t(2:end-1,2:end-1) = false out = sum(a(t))

10 years ago | 2

Answered
Help finding the min and max of a matrix without using min/max commands
mn = mat2(1); mx = mat2(1); for ii = 2:numel(mat2) if mat2(ii) < mn mn = mat2(ii); imn = ii...

10 years ago | 0

Answered
I divided a mxn matrix into several equal ixj matrices using mat2cell. But I wanna average all values in ixj .
%B = cell array with size iiXjj out_mean_value = cellfun(@(x)mean(x(:)),B);

10 years ago | 0

| accepted

Answered
How to generate a random matrix with conditions?
[m,n] = size(A); X = zeros(m,sum(A,2) + n - 1); a = arrayfun(@(x)ones(1,x),A,'un',0); Xc(:,1:2:2*n-1) = a ; Xc(:,2...

10 years ago | 0

Answered
Command to reshape matrix diagonally
% X - array with size [5541888 x 7] % m2 - number of rows in second array, m2 = 1536 [~,n] = size(X); out = resha...

10 years ago | 0

| accepted

Answered
Mean automation from excel data
ps = xlsread('yourdata.xlsx'); [speed,~,c] = unique(ps(:,2)); pressure_mean = accumarray(c,ps(:,1),[],@mean); out = [...

10 years ago | 1

| accepted

Answered
comparing numbers on the same vector
out = all(bsxfun(@ge,x,x') + triu(ones(numel(x)),1),2);

10 years ago | 0

Answered
How to find 6 clusters
A = A(:); l = A > 0; z = cumsum([l(1);diff(l)==1]); out = accumarray(z(l),A(l),[],@(x){x});

10 years ago | 0

| accepted

Answered
How to perform this matrix manupulation.?
z = circshift(1:20,[0 3]'); out = hankel(z,rem((z(end):z(end)+6)-1,20)+1);

10 years ago | 0

| accepted

Answered
how to add ones to binary matrix with condition to add them ?
A1 = fliplr(A); D = bsxfun(@times,C(:,end),fliplr(cumsum([A1(:,1),diff(A1,1,2)==1],2).*A1)) == 1; on <http://se.mathwor...

10 years ago | 0

Answered
Indexing a cell array according to another cell array
n = repelem(1:numel(A),cellfun(@numel,A)); B1 = [B{:}]; A1 = [A{:}]; t = A1 ~= 3 & (A1 < 7 | A1 > 9); out = accuma...

10 years ago | 1

| accepted

Answered
find if there are more then 10 consecutive NaN values
i1 = find(diff([0 A 0]) == 1); out = i1(find(diff([0 A 0]) == -1) - i1 > 10);

10 years ago | 0

Answered
Function to find number of 1 in binary Matrix for each row and for each coulmn
for columns A = MatrixA; a1 = cumsum([A(1,:);diff(A)==1]).*A+1; [m,n] = size(a1); q = accumarray([a1(:),kron((1:n)...

10 years ago | 0

Answered
How to store elements in loops and display into two separate vectors?
A=[1,2,3,4]; even=[]; odd=[]; for idx=1:numel(A); element=A(idx); if mod(element,2)==0; eve...

10 years ago | 0

Answered
Sum the elements in cell array with different element length
m = cellfun(@numel,trial); k = num2cell(max(m(:))-m); out = cellfun(@(x,y)[x(:); nan(y,1)]',trial,k,'un',0); EDIT ...

10 years ago | 1

| accepted

Answered
Add a time series of data in the z direction to each cell in a matrix
Let |W| - your array of time series weather data with size [1x717]; |L| - your matrix of coordinates [330x596]. [m,n] = ...

10 years ago | 0

Answered
How to replace duplicate elements as 0 in column matrix
Output = cumsum(cumsum(Input)) == 1; Output = Output(any(Output,2),:)

10 years ago | 0

| accepted

Answered
Find matching values in matrix B for multiple values in matrix A.
Arow = (1:numel(A))'; [~,Brow] = ismember(A,B);

10 years ago | 0

| accepted

Answered
Split a larger matrix into smaller matrices
C = num2cell(M,[1 3]);

10 years ago | 2

Load more