could anyone help me how to update the array values with respect to the following arrays
a = (1:max(C))'; b = accumarray(C,1); i = a(accumarray(C,1) > 1); [lo,ii] = ismember(C,i); AA = A(lo,:); [iii,j] = ndgrid(i...

6 days ago | 0

Create a matrix on the basis of other matrix
[~,j] = find(M); C = accumarray(j,M(M ~= 0),[],@(x){unique(x,'stable')}) if all(diff(cellfun(@numel,C)) == 0) C = [C{:}];...

7 days ago | 0

How to specify a number to the specified position in the array？
a = [2 3 5 7 11]; out = [a;flip(a,2)]; out = out(1:numel(a));

7 days ago | 0

| accepted

Return a vector with the same size as the indexing matrix/vector (code optimization)
General case: out = reshape(V(index),size(index)); For your case V - vector (n x 1): if size(index,1) == 1 out = V(index...

7 days ago | 1

Use vec = -1:-1:-5 or vec = -(1:5)

7 days ago | 0

Finding and counting of identical rows in a matrix
For Octave? M = [ 1 300 3500 500 6000 3 200 3000 500 6500 5 150 2500 450 6000 8 400 2000 550 5500 5 200 3000 500 6500 ...

10 days ago | 1

| accepted

Collect double values of a matrix
Let xyz - your array (n x 3); [~,~,c] = unique(xyz(:,[1,3]),'rows','stable'); % c - serial numbers of rows with same values in ...

12 days ago | 0

Another Datetime conversion problem!
DateStrings = '2019-10-04T11:41:06+01:00'; convertDATETIME=datetime(DateStrings,'InputFormat',... 'uuuu-MM-dd...

12 days ago | 0

| accepted

Finding consecutive data with non zero in array
for R2013a (and for your data from all_data.txt) f = fopen('all_data.txt'); Data = textscan(f,'%f %f %f %f %f %f %f','CollectO...

16 days ago | 0

| accepted

Rearrange randomly just some parts of an array
C = [1 2 1 2 1 2 1 2 4 2 4 2 4 2 4 2 6 2 6 2 6 7 6 7 6 7 6 7 7 7 7 7 8 8 8 8 9 9 9 9 ]; CC = [C(:);max(C(:))+1]; j = 1; for...

18 days ago | 0

| accepted

Delete some specific numbers from an array
A = [10 9 5 5 7 3 5 8 3 5 6 3 7 10 ]; B = sign(diff(A(hankel(1:3,3:numel(A)))',1,2)); out = A( [true; prod(B,2) ~= 1 ; true...

18 days ago | 0

Help creating a vector in a loop
n = numel(A); new_vector = zeros(25,n); for ii = 1:n new_vector(:,ii) = linspace(A(ii),B(ii),25); end

19 days ago | 0

Subscript indices must either be real positive integers or logicals. how can i change? thanks!
ii(1) = v0; %initial condition for loop=2:N %recursive ii(loop) = ii(loop-1) + Vs*dt*/L - ii(loop-1)*R/L; end

19 days ago | 0

How to randomly place ones in specified postions of a matrix?
1. k = 10; [m,n] = size(A); [i1,j1] = ndgrid(1:m,1:2); [i2,j2] = ndgrid(1:3,3:n); ii = sub2ind([m,n], [i1(:);i2(:)],[j1(:);...

19 days ago | 0

| accepted

Error in Vector Multiplication of Complex Numbers
>> [a,b]*[a;b] ans = -3 >> [a,b]*[a,b].' ans = -3 >> [a,b]*transpose([a,b]) ans = -3 >> [a,b].' ans = ...

20 days ago | 0

| accepted

How to calculate averaged values from 5-min interval values
T = readtable('parko_hourly_1_1_2015_eos_16_5_2015_T_RH MINE.xlsx','sheet','Φύλλο1'); T = T(~isnan(T.minute),[1:5,7:8]); T.YEA...

20 days ago | 0

how to apply two statement in if loop?
if all(A(:)>0) & all(ismember(A(:),B(:))==0) .. end

21 days ago | 1

| accepted

Rearrange elements in an array based on another array
s = sum(M,2); v = V.*(M == 0); ss = s - sum(v,2); lo = ss > 0; n = sum(v == 0,2); a = fix(ss./n); b = mod(ss,n); add = ar...

25 days ago | 0

| accepted

Matrix from an array
A=1:15; n = 6; k = 3; m = numel(A); B = A((1:k:m - n + 1)' + (0:n-1)); % for old MATLAB < R2016a B = A(bsxfun(@plus,(1:k...

25 days ago | 1

| accepted

Generating sequences from data
xy = [5 14 6 16 1 16 6 11 4 16 1 16 2 13]; n = 5; [m,k] = size(xy);...

25 days ago | 0

| accepted

Combining several asymmetric matrices to fit each other
m = [1 1 1 1 1 1 1 1 1 NaN 1 1 1 NaN NaN 1 1 NaN NaN NaN ...

26 days ago | 2

How to compare two vectors on distance and isolate consecutive segments?
d = abs(A(:) - B(:)') <= 40; loA = any(d,2); loB = any(d,1); output = zeros(nnz([loA(:);loB(:)]),1); output(1:2:end) = A(loA...

27 days ago | 1

Masking an array back to a selected region in a Matrix
out = double(region); out(region) = vdisp_selected;

28 days ago | 0

| accepted

How do I subtract two 2D data sets with different resolutions?
PP1 = interp1(T1,P1,T2); dP21_out = P2 - PP1; plot(T2,P2); hold on plot(T2,PP1);

28 days ago | 0

| accepted

i want to calculate of mean each block row vice and i need to replace each row with obtained mean value
Let A - your array: A = randi(125,8,6); out = mean(A,2)*ones(1,size(A,2));

28 days ago | 0

How to create a block diagonal matrix without using cell array?
A(:,:,1) = [1 2 3 ; 4 5 6]; A(:,:,2) = [7 8 9 ; 10 11 12]; C = num2cell(A,[1,2]); B = blkdiag(C{:}); or for your case (A -...

28 days ago | 0

| accepted

Nearest value from an array.
M=[1,2,3,4,5,6,7,8,910] N=[0.5,1.3,2.4] [~,ii] = min(abs(M(:) - N(:)')); out = M(unique(ii));

1 month ago | 0

| accepted

Selecting cross values from two arrays
s = [0,1000,2000]; d = [0,1000,2000]; J = [0,5000,8000]; ii = fullfact([3,3,3]); out = [s(ii(:,1))',d(ii(:,2))',J(ii(:,...

1 month ago | 0