Answered
Add matrix to matrix
B = {B1;B2;B3;B4...;Bi}; % Please create B array. n = cellfun(@numel,B); A = [cell2mat(B),repelem((1:numel(n))',n)];...

8 years ago | 0

| accepted

Answered
I need to do some matrix manipulation for a longitudinal study. See description and image below.
A - your array; out = [kron(A(:,1),ones(size(A,2)-1,1)), reshape(A(:,2:end)',[],1)]

8 years ago | 0

Answered
Swapping the elements in a matrix
A = [0.8 0.7 0.9 0.5;0.6 0.4 0.9 0.7;0.8 0.5 0.6 0.5;0.8 0.6 0.5 0.4]; n = size(A,1); for ii = rem(0:(n-1)^(n-1)-1,n-1...

8 years ago | 0

Solved


Test for balanced parentheses
Given the input inStr, give the boolean output out indicating whether all the parentheses are balanced. Examples: * If ...

8 years ago

Solved


Pattern matching
Given a matrix, m-by-n, find all the rows that have the same "increase, decrease, or stay same" pattern going across the columns...

8 years ago

Solved


square number
Square a number

8 years ago

Solved


Function Iterator
Given a handle fh to a function which takes a scalar input and returns a scalar output and an integer n >= 1, return a handle f...

8 years ago

Answered
How to call index of vector in matrix?
A = [... 6 -3 4 7 8 -5 -4 8 6 7 1 8 3 6 4 ...

8 years ago | 1

Solved


Knight's Tour Checker
Given a matrix a, determine whether or not a legal <http://en.wikipedia.org/wiki/Knight's_tour knight's tour> is present. The kn...

8 years ago

Answered
how to find the second most repeated value in vector
[g,v] = findgroups(x); ii = accumarray(g(:),1); jj = find(ii > 1); out = [v(jj(2)), ii(jj(2))]

8 years ago | 2

Answered
What is the best way to create a 10x11 matrix from a 2x100
Let A - your matrix [100 x 2] b = sortrows(A); out = [unique(b(:,1)), reshape(b(:,2),[],10)];

8 years ago | 1

Answered
How to use a vector for filling columns of table
cell2table([{num2str(457888)}, {'error'}, num2cell(zeros(1, size(new_table,2)-2))])

8 years ago | 1

| accepted

Answered
How do you use ndgrid
Lengths = [1, 20,40,60,75]; Angle = [.7999,.9002,.9999,1.1001,1.1999]; A = rand(5,5); [x,y] = ndgrid(-5:0.8:5); ...

8 years ago | 1

Answered
how to horizontally concatenate two strings, being one a cell array and the other a num2str converted gpuarray?
C = { 'CELL:','CELLA:','CHAR:','GCH4:','GH2:' } S = string(C) + [.1:.1:.5;.1:.2:.9] out = join(S,',');

8 years ago | 0

Answered
Average timestamp 20 seconds interval data into hourly
for older version MATLAB: T = readtable('data.xls'); [Y M D H] = datevec(T{:,1}); [~,~,T.groups] = unique([Y M D H],'...

8 years ago | 0

Solved


Target sorting
Sort the given list of numbers |a| according to how far away each element is from the target value |t|. The result should return...

8 years ago

Solved


Counting Sequence
Given a vector x, find the "counting sequence" y. A counting sequence is formed by "counting" the entries in a given sequence...

8 years ago

Answered
Replace each element of a matrix with the number it is closest to in a set of discrete values without using for loop
A = [2 4], B = [1.1, 3.2, 5, -17] [~, ii] = min(abs(bsxfun(@minus,B(:),A(:).')),[],2); % MATLAB <= R2016a [~, ii] = ...

8 years ago | 1

| accepted

Answered
Delete rows with characters in cell array
My ruble: A={'1 TITLE 13122423'; '2 NAME Bob'; '10 PROVIDER James'; '44 234 456 234 345'; '48 344 454 462 435';...

8 years ago | 3

| accepted

Answered
How to split divide an array on specific sections?
GC = accumarray(data(:,1),(1:size(data,1))',[],@(x){data(x,:)});

8 years ago | 3

Solved


Which values occur exactly three times?
Return a list of all values (sorted smallest to largest) that appear exactly three times in the input vector x. So if x = [1 2...

8 years ago

Solved


Who Has the Most Change?
You have a matrix for which each row is a person and the columns represent the number of quarters, nickels, dimes, and pennies t...

8 years ago

Solved


Fibonacci sequence
Calculate the nth Fibonacci number. Given n, return f where f = fib(n) and f(1) = 1, f(2) = 1, f(3) = 2, ... Examples: Inpu...

8 years ago

Answered
Averaging points within data set
x=importdata('yourfile.txt'); xavg=accumarray(rem((0:numel(x)-1).',720)+1,x(:),[],@mean);

8 years ago | 0

| accepted

Answered
create matrix from loop in matlab
[ii,jj] = ndgrid(1:400); x = [ii(:),jj(:)]; a = round(atan2d(200 - ii(:), jj(:) - 200)); idx = discretize(a,0:5:90); ...

8 years ago | 1

Answered
Find the midpoint between the two points (1, -7) and (-1, -23).
homework? P1 = [1, -7]; P2 = [-1, -23]; out = (P1(:) + P2(:)).'/2

9 years ago | 3

| accepted

Answered
How to create a vector with several repetitions of a random permutation
x = 1:4; ii = 2; x1 = repmat(x(:)',1,ii); out = x1(randperm(numel(x1)))

9 years ago | 2

| accepted

Answered
Adding a row vector to multiple rows of a matrix, with duplicate row index
ii = [1;2;1]; a = unique(ii); A(a,:) = A(a,:) + accumarray(ii,1)*[1, 1]

9 years ago | 0

Answered
cumsum reset back to zero every 100 times
with "zeros" m = 100; n = numel(R); R1 = R(:); R1(m+1:m:n) = 0; d = accumarray(ceil((1:n)'/m),R1); R1(m+1:m:...

9 years ago | 0

Load more