Respondida
How to superimpose an matrix image into the center of a zero matrix (MATLAB CODE)?
z = zeros(14); b = randi(100,5,8); sz = size(z); sb = size(b); bb = floor((sz - sb)/2)+1; z(bb(1)+(0:sb(1)-1),bb(2)+(0:...

más de 7 años hace | 0

| aceptada

Respondida
How to efficiently encode two values as a unique entitiy
in your case: >> A=[3;3;3;1]; B= [1;1;3;1]; f = @(A,B) 3*(A(:) - 1) + B(:); C = f(A,B) C = 7 7 9 1...

más de 7 años hace | 1

Respondida
Which function should I use here to group my matrix?
[~,ii] = sort(abs(A(:,1))); B = A(ii,:);

más de 7 años hace | 1

| aceptada

Respondida
assign the same vector to be the same cell
Cell = mat2cell(A,accumarray(findgroups(A(:,2)),1),size(A,2));

más de 7 años hace | 0

Respondida
finding the mean and max
EDITED >> XXX =[ 1 1 1 2 2 1 1 3 1 ; 2 3 2 4 6 9 7 8 9]' XXX = 1 2 1 3 1 2 2 4 2...

más de 7 años hace | 1

Respondida
How to search and extract text segment from a character array?
c = cellstr(hdr); out = str2double(... regexp(c,'(?<=(testdevice\.x|testdevice\.у)\s*\:\s*)\-?\d*','match','once')); out ...

más de 7 años hace | 0

Respondida
How can I get a 'random index' of unique elements in a matrix rather than first/last index ?
M = [2;2;2;2;2;1;1;1;1;3;5;5;5;5;6;6;4;4;4]; [~,b,c] = unique(M); out = round(rand(numel(b),1).*(accumarray(c,1) - 1)) + b; ...

más de 7 años hace | 0

Respondida
Accumulate rain events with determined dry period
load('ex_rain.mat') TT = timetable('RowTimes',datetime(example(:,1:6)),example(:,7),'v',{'rain'}); TT1 = retime(TT,'daily','su...

más de 7 años hace | 0

Respondida
how to find zeros of a matrix ?
A = [1,2,3,0,0,5;8,0,3,0,9,9]; AA = A'; AA = AA(:)'; lo = AA ~= 0; out = AA([strfind(lo, [1 0]);strfind(lo, [0 1])+1]');

más de 7 años hace | 1

| aceptada

Respondida
How to filter excel dataset into specific time range and scan for missing values?
T = readtable('test.xlsx','ReadV',0,'Range','A3:C217'); a = datevec(T.Var1); [ymd,ii] = unique(a(:,1:4),'rows','first'); Da...

más de 7 años hace | 1

| aceptada

Respondida
How to incorporate a conditional nonzero statement for multiple columns
D =[ 6 2 6 3 0 0 4 1 3]; out = D > 0; out(sum(out,2) > 1,:) = 0;

más de 7 años hace | 0

| aceptada

Respondida
how to convert hourly data to daily data by taking average of hourly data?
load('PM_SD_CHENNAI.mat') date1 = (datetime(2015,1,1,1,0,0):hours(1):datetime(2018,9,1,0,0,0))'; PM_SD_CHENNAI = PM_SD_CHENNAI...

más de 7 años hace | 1

| aceptada

Respondida
How to find out the maximum number of occurrences of the sequences inside the cell array beginning with particular digit?
C = {[1; 2; 3]; [2; 1; 3; 4]; [ 4; 2; 1; 3];[3; 1; 2]; [1; 2]}; a = perms(1:3); [~,j2] = cellfun(@(x)ismember(a,x),C,'un',0)...

más de 7 años hace | 0

| aceptada

Respondida
finding the mean and reducing the value
y = [1 1 1 2 1 1]'; x = [ 0.01 0.02 0.034 0.045 0.054 0.06]'; ii = [true;diff(y(:)) ~= 0]; x1 = accumarray(cumsum(ii...

más de 7 años hace | 0

| aceptada

Respondida
How to find the maximum value among values less than a certain value?
A = cellfun(@(x)x(:),your_cell_array),'un',0); A = sort(cat(1,A{:})); out = A(find(A < certain_value,1,'last'));

más de 7 años hace | 0

Respondida
how can i add a 3dim matrix to another one as every odd cell
s = size(B); out = zeros(c .* [1,1,2]); out(:,:,1:2:s(3)*2) = A(:,:,1:s(3)); out(:,:,2:2:s(3)*2) = B;

más de 7 años hace | 0

| aceptada

Respondida
How to detect ones and its location in a column
in your case (for vector): location = find(A);

más de 7 años hace | 1

| aceptada

Respondida
How to split a row vector into sub vectors with different sizes?
h = [1 2 3 4 5 6 7 8 9 10 11]; n = [3, 3, 2, 2]; m = mat2cell(h(2:end),1,n)

más de 7 años hace | 1

| aceptada

Respondida
How many times does a pair of value occur in a row?
a = nchoosek(1:4,2); d0 = repelem(dat',2,1); d0 = d0(2:end-1,:); out = squeeze(sum(all(sort(reshape(d0,2,[],2)) == reshape(a'...

más de 7 años hace | 1

Respondida
accumarray function for equal integer values
B1 = [34.1; 34.2; 35.6; 35.7]; B2 = [600; 800; 200; 100]; B = table(B1,B2); B.B1 = round(B.B1); Bnew = varfun(@sum,B,'Grou...

más de 7 años hace | 1

Respondida
find matching values from two unequal size arrays
Let: a = [lat1 lon1 pCO2]; b = [lat2 lon2]; b(:,3) = a(ismember(a(:,1:2),b,'rows'),3);

más de 7 años hace | 0

Respondida
how do I create this loop?
zrs = zeros(size(TT,1),1); TT.G = zrs; TT.SG = zrs;

más de 7 años hace | 0

Respondida
cut x and y array on datetime
lo = x(x <= specific_date); y_out = y(lo);

más de 7 años hace | 0

| aceptada

Respondida
How do i find the product of all the numbers in my matrix
prod(1:20)

más de 7 años hace | 0

Respondida
Replace groups of numbers in a matrix checking connections in 8-directions
<https://www.mathworks.com/matlabcentral/answers/425576-replace-numbers-in-a-matrix-depending-on-the-shape-in-which-a-group-of-n...

más de 7 años hace | 1

Respondida
Assign Field to Structure Array without a Loop
cellarray = num2cell([Field1(:),Field2(:)]); namefields = {'Field1','Field2'}; StructArray = cell2struct(cellarray,n...

más de 7 años hace | 1

Respondida
How to transpose values of arrays between matrices
z = z(:)'; zz = z(59472:59555); out = zz(Indices);

más de 7 años hace | 0

| aceptada

Respondida
Replace numbers in a matrix depending on the shape in which a group of numbers are located
out = 2 - A; cc = bwconncomp(out); z = cc.PixelIdxList; n = cellfun(@numel,z) >= 3; idx = z(n); zz = cellfun(@(...

más de 7 años hace | 1

| aceptada

Respondida
How to multiply all values in the diagonal of a matrix by -1 in Matlab?
max(a21(:),a21(:)').^2 .* (ones(5) - 2*eye(5));

más de 7 años hace | 0

Respondida
How to build a matrix of 0, 1 and 2 according to the answers made by individuals of a survey
ABC = [3,8 11,15 9,9]; s = size(ABC); [ii,~] = ndgrid(1:s(1),1:s(2)); out = accumarray([ii(:)...

más de 7 años hace | 1

| aceptada

Cargar más