Answered
How to replace values in a matrix according to the reference matrix
just out = B(A,:) or general case [~,ii] = ismember(A,B(:,1)); out = B(ii,:);

9 years ago | 0

| accepted

Answered
How to generate sequence numbers
out = ones(numel(A)+1,1); ii = [true;diff(A)~=0]; jj = diff(find([ii;1])); out(ii) = out(ii)-[0;jj(1:end-1)]; out ...

9 years ago | 0

Answered
Changing numbers in a matrix by checking values
[EDIT] a = [0 1 0;1 0 1]; [l0,ii] = ismember(Ende,[1 1 0;1 1 1],'rows'); Ende(l0,:) = a(ii(l0),:);

9 years ago | 0

Answered
Compare matrices with datenum
out = B(A(month(B(:,1))) <= B(:,end),:);

9 years ago | 0

Answered
How do I identify each element in a cell array as a string or a number?
out = cellfun(@ischar,A)

9 years ago | 0

| accepted

Answered
Finding number of certain value in each row
AvgX = 8; A = [3 7 10 6 9 12 1 5 6]; out = sum(AvgX < A,2);

9 years ago | 1

| accepted

Answered
sub2ind - get all of 3rd dimension
*EDIT* without |sub2und| l0 = label == 41; k = size(feature_map,3); sub_feature_map = reshape(feature_map(repmat...

9 years ago | 1

Answered
How to Text Scan and remove columns full of zeros?
T = T(:,any(T{:,:}));

9 years ago | 1

Answered
consecutive rows to define an event
Let |A| - your dataset with size [N x 2] Using |Image Processing Toolbox| 1. S = regionprops(cumsum(diff([0;A(:,2)])...

9 years ago | 0

Answered
Find negative in every n rows
One way % A - your data [2184 x 14] ii = ceil((1:size(A,1))'/24); jj = accumarray(ii,A(:,14),[],@(x)all(x >= 0)); % E...

9 years ago | 0

| accepted

Answered
can you solve this using matlab function?
Use functions |syms, solve, vpa, subs| from |Symbolic Math Toolbox|. Other way use function <http://se.mathworks.com/help/mat...

9 years ago | 0

Answered
How to multiply two matrices
A - vector 2749 x 1 B - vector 500 x 1 A1 = reshape(A(1:2*749),749,[]); out = A1(1:500,:).' * B; % dot-...

9 years ago | 1

Answered
How do I define a piecewise function using special conditions?
f = input('Enter the function: ','s') % enter expression: 3-5*rem(n,2) f = str2func(['@(n)',f]) use |f|: >> f(1:10...

9 years ago | 0

Answered
How do I remove NaN individually and keep the shape of my matrix
N = V ~= 0; out = V(all(N,2)&all(N)); % MATLAB >= R2016b out = V(bsxfun(@and,all(N,2),all(N))); % MATLAB < ...

9 years ago | 0

Answered
Varargin - mistake in my example
use: ingressi_arbitrari(2,3)

9 years ago | 0

Answered
Error using contour: Z must be at least a 2x2 matrix.
Your typo Should be: contour(X,Y,f(X,Y));

9 years ago | 1

| accepted

Answered
how to solve tan(2x)=-5x
example for interval -10*pi:10*pi f = @(x,w)tan(w*x)+5*x w = 2; % in your case x = -10*pi+pi/(2*w):pi/w:10*pi-pi/(2*w...

9 years ago | 0

Answered
Reduce number of outputs in workspace
hypot(a(:,1) - a(:,1)',a(:,2) - a(:,2)') or from |Statistics and Machine Learning Toolbox| squareform(pdist(a))

9 years ago | 1

Answered
Extract values by matching column values
[C,ia,ib] = setxor(a',b','rows'); out = C';

9 years ago | 0

Answered
Q90 percentile for monthly time series
s = size(a); a1 = reshape(a, s(1), s(2), 12 , s(3) / 12); a2 = prctile(a1,90,4); b1 = reshape(b, s(1), s(2), 12 , s(3...

9 years ago | 0

| accepted

Answered
How can I vectorize this code ?
C = rot90(filter2(A,B,'valid'),2); or C = conv2(rot90(B,2),A,'valid');

9 years ago | 1

| accepted

Answered
Help turning a permutation function into a script.
M = V(fliplr(fullfact(ones(1,N)*numel(V))))

9 years ago | 0

Answered
How to add group of diagonal vectors in a matrix
Let |A|- your array. A = randi(1e4,9800,49); [m,n] = size(A); k = 200; A_out = sum(A(sub2ind([m,n],reshape(1...

9 years ago | 1

| accepted

Answered
Create matrix based on the row numbers
C = B(A);

9 years ago | 2

Answered
If loop to know if event happens on a matrix then 1, how to do it?
iw = [13 1 14 1 42 2 52 3 63 3]; any(ismember(iw,[13, 1],'...

9 years ago | 0

Answered
numbers in random positions on a zero matrix
m = 5; n = 4; T = [2 2 3 ones(1,9) zeros(1,8)]; out = reshape(T,m,[]); [~,ii] = sort(rand([m,n]),2); out = out(...

9 years ago | 1

| accepted

Answered
How can I create the matrix in the photo?
m = [1.2000 2.4000 1.3000 2.3000 1.5000 1.0000]; r = [0.2000 0.4000 0.3000]; K = permute(m,...

9 years ago | 0

| accepted

Answered
Help with a for-loop of an array of iterative matrices
t = (1:16:145) + (0:5)'; experiment = zeros(72,10,4); for ii = 1:4 rep = xlsread(sprintf('%d.xlsx',ii),'B9:M158')...

9 years ago | 1

Load more