Community Profile

photo

Andrei Bobrov


4,631 total contributions since 2011

Andrei Bobrov's Badges

  • Thankful Level 3
  • Master
  • 36 Month Streak
  • Revival Level 2
  • Knowledgeable Level 4
  • First Answer
  • Scavenger Finisher
  • CUP Challenge Master
  • Commenter
  • Leader
  • Speed Demon
  • Solver

View details...

Contributions in
View by

Answered
How to repeat the condition for two matrices having different sizes?
I edited the answer. out = A > B(:,:,mod(0:size(A,3)-1,size(B,3))+1);

4 hours ago | 1

Answered
How to concentrate matrices of different row length (same column length) into one matrix by unfolding each of the matrices to the smallest row length conatining numbers not nan
M = struct2cell(H); n = min(cellfun(@(x)find(all(~isnan(x),2),1,'last'),M)); M = cellfun(@(x)reshape(x(1:n,:)',1,[]),M,'un',0)...

5 hours ago | 1

| accepted

Answered
How to reset the sequence number for the sequence number in vector?
In your case: [~,~,vec2] = unique(vec);

6 hours ago | 3

| accepted

Answered
How to multiply each element of a matrix by another matrix
Use function kron: >> B = reshape(1:9,3,[]) B = 1 4 7 2 5 8 3 6 9 >> A = 2*[1,1;1...

6 hours ago | 0

| accepted

Answered
simple code for the log computation
X = [1, 2, 3, 5, 6]; M = log10(X);

1 day ago | 1

Answered
select rows satisfying a particular condition
% Let A - your array. [ii,jj,v] = find(A); z = [ii,jj,v]; z = sortrows(z,[1,2]); out = accumarray(z(:,1),z(:,3),[],@(x){fu...

1 day ago | 1

| accepted

Answered
How to find the given index values in a array?
in R2016b T = readtable('Sheet2.xls','ReadVariableNames',0); lo = T{:,2:end} ~= 0 & ~isnan(T{:,2:end}); [ii,~] = find(lo); o...

1 day ago | 1

| accepted

Answered
Check common elements in two vectors and remove them from both the vectors leaving any duplicate. (Example Inside)
a1 = unique([A(:);B(:)]); s = size(a1); [~,iA] = ismember(A(:),a1); [~,iB] = ismember(B(:),a1); ii = (accumarray(iA,1,s) - a...

2 days ago | 0

Answered
Row index exceeds matrix dimensions
T = array2table(A); m = varfun(@mean,T,'GroupingVariables',1); out = A; [~,~,ii] = unique(A(:,1)); out(:,2:end) = out(:,2:en...

2 days ago | 1

| accepted

Answered
Using kron to create a large matrix
n = 11; A = [-4 2 0;1 -4 1;0 2 -4]; %main diagonal m = size(A,1); mn = m*n; o1 = ones(mn,1); out = full(spdiags([o1,repma...

2 days ago | 0

| accepted

Answered
placement of elements from a matrix into another matrix
%{ block of code by Rupsana - initial and final submatrix values and initial matrix A: %} tot_row=5; tot_col=10; left_co...

2 days ago | 1

| accepted

Answered
A command like "unique" for matrices?
A=[1;2;3]; C=[4;5;6]; M = [repmat(A,2,1);C]; out = reshape(unique(reshape(M,3,[])','rows','stable')',[],1);

3 days ago | 1

Answered
How can i seperate a string in all possible smaller ones without using for loops;.
a = 'ATGCA'; out = cellstr(a((1:end-1)' + [0, 1]));

3 days ago | 0

Answered
How to make faster row-wise Matrix multiplication ?
Just use: out = permute(A,[3,2,1]).*B;

4 days ago | 1

| accepted

Answered
short programs to subtracts rows from a matrix of n length
Z = squeeze(sqrt(sum((T - permute(X,[3,2,1])).^2,2)));

4 days ago | 0

| accepted

Answered
How would I put this in a for loop ?
T = 1; % Period Vm = 1; % Voltage amplitude v = {@(t)Vm*sin(4*pi*t/T); @(t)2*Vm*sin(4*pi*t...

4 days ago | 0

Answered
How do I create a random row matrix with some fixed positions?
a = [ 11 3 14]; b = 1:20; c = setdiff(b,a); n = numel(c); out = [a, c(randperm(n))];

5 days ago | 0

| accepted

Answered
Rearrange matrix and concatenate cells
If your datadimer is table: A = datadimer{:,:}; sZ = 291; [m,n] = size(A); k = m/sZ; out = reshape(permute(reshape(A,sZ,k,n...

5 days ago | 0

Answered
return row index of values greater than 0 to a 3 dimensional array
[ii,jj] = find(A > 0); out = accumarray(ii,jj,[],@(x){sort(x)'}); out{:}

5 days ago | 0

Answered
How to crop matrices at the maximal non-NaN values and then center the data
M = struct2cell(H); n = min(cellfun(@(x)find(any(isnan(x),2),1,'first')-1,M)); for jj = 1:numel(H) H(jj).matrix = H(jj).m...

5 days ago | 1

| accepted

Answered
How can I extract the time column of a timetable
variant a = rand(20,6); date1 = datetime(2019,4,19) + hours(cumsum(70*rand(20,1))); TT = array2timetable(a,'RowTimes',date1...

6 days ago | 1

| accepted

Answered
combining two text file with 100 equal number of header and body text
z = dir('file*_.txt'); zn = {z.name}; n = numel(zn); c = cell(n,1); for jj = 1:numel(zn) f1 = fopen(zn{jj}); k = t...

7 days ago | 0

| accepted

Answered
How to assign NaN for empty cells in an array?
Finalanswer = ismember(T.Icnum,moga);

7 days ago | 1

Answered
How does Matrix(3002:2001:1999998)=0.4 works?
[ii,jj] = ind2sub([1000,2000],3002:2001:1999998); A = sparse(ii,jj,.4,1000,2000);

7 days ago | 0

Answered
Matrix problem with my vectors
theta = (-5:5:25)';%+ n = numel(theta); N = [-0.906 1.43 2.78 4.20 5.03 5.28 -2.49 0.889 4.16 7.71 11.0 7.30 12.7]*4.45; FN_c...

8 days ago | 0

Answered
How to subtract a number from a previous one
x = [1;.75;.5;.6]; n = filter(1,[1;1],x); or out = tril(toeplitz(x))*(-1).^(2:numel(x)+1).'; or n = x; for jj = 2:numel(...

8 days ago | 2

| accepted

Answered
how to adjust the conv filtered data same like origanal data?
con=conv(h,L,'same');

8 days ago | 0

| accepted

Answered
how to count the number of element in observation and make summation?
K = B.TotalRevenue.*ones(size(B,1),3)/3; [a1,~,c1] = unique(B{:,1:3}); out = table(a1,accumarray(c1,K(:)),'v',{'opals','Revenu...

8 days ago | 0

| accepted

Answered
Create This Matrix to N-Value
n = 3; out = flip(fullfact([n, n]),2) - 1; or [x,y] = ndgrid(0:n-1); out = [y(:),x(:)];

10 days ago | 0

| accepted

Answered
How to extend/add elements to an array?
A = [2 3 4 5 0 1 4 5 5 0 3 4 0 2 0 ]; B = [3 2 3 5]; out = A(sort([find(A),repelem(find(A == 0),B)]));

10 days ago | 0

| accepted

Load more