Respondida
I need help with for loops with if statements. I'm trying to get it to output [P,O,O,O,P​,O,P,U,U,O​,O,O,U,O,O​,A,A,A,P,P​,G,O,U,U,G​,A,P,O]. thx
volt=[18 33 31 34 15 37 10.5 48 50 38 35 39 42 33 31 1 5 9 13 11 27 35 -1 46 22 6 19 36]; ABS = sprintfc('%c','UAPGOU'); [~,...

casi 7 años hace | 1

Respondida
find frequency and duration of numerical events in a matrix
Let A - your array (1440 x Days): k = 60;% k = 60 (minuties in hour) [m,n] = size(A); a1 = A ~= 0; A1 = diff([false(1,n);a1]...

casi 7 años hace | 0

| aceptada

Respondida
How to take 3 elements at a time from an array and turn them into their own column vector?
msg = 'gfewqaxcvbhgf'; % example [~,C] = ismember(msg,'a':'z'); C = C - 1; out = reshape([C(:);zeros(mod(-numel(C),3),1)],3...

casi 7 años hace | 1

| aceptada

Respondida
How to use 'for' in this example?
a = [y11(:)';y22(:)';y33(:)';y44(:)';y55(:)';y66(:)']; aaa = reshape(repelem(a,1,2),1,[]);

casi 7 años hace | 0

| aceptada

Respondida
Finding the first and the last elements of consecutive numbers and combining them with a semi colon.
ii = cumsum([true,diff(outliers)~=1]); A = accumarray(ii(:),outliers(:),[],@(x){[min(x),max(x)]}); out = reshape([A{:}],2,[])'...

casi 7 años hace | 1

| aceptada

Respondida
Interating through a table data set
sex = {'F';'M'}; age = [55;40]; [~,~,ii] = histcounts(age,agetable.agelow); [lo,jj] = ismember(sex,{'F','M'}); at = agetab...

casi 7 años hace | 0

| aceptada

Respondida
Only the value corresponding to the last loop of a for loop being saved in the output array
c = 12000; k = (1:20)'; soc = k*c/numel(k); lo = ismember(round(data(:,16)),soc); ocv = data(lo,14);

casi 7 años hace | 1

| aceptada

Respondida
How to randomly interchange values in different rows in a matrix
[m,n] = size(A); At = A.'; [~,ii] = sort(rand([n,m])); cutpoint = find(ii == 1); i0 = zeros([n,m]); i0(1,:) = 1; i0(ccutpo...

casi 7 años hace | 0

Respondida
HOW TO CREATE THİS MATRİX
hankel(0:99,(0:99)+99);

casi 7 años hace | 0

Respondida
How to filter a table in matlab and then assign a value using a loop
Let T - your table x = sum([ismember(T{:,1:3},categorical({'pT2','pT3','pT4','pN2','N3','G3'})),... ...

casi 7 años hace | 1

Respondida
Cite the error number
M = randi([1,200],15,8); S = flip(string(['A':'D','F']'),1) [~,~,a] = histcounts(M,[-inf,60:10:90,inf]); out = S(a);

casi 7 años hace | 0

Respondida
Group cell array and vector for "for loop and if statement"
mat.xlsx - file with your data T = readtable('mat.xlsx'); [~,jj] = sortrows(T(:,2:4)) out = T(jj,:);

casi 7 años hace | 0

Respondida
Faster than find on all the colomns
a = rand(5,15)>.7; K = 100; lo = cumsum(a) > 1; a(lo) = a(lo)*K;

casi 7 años hace | 1

| aceptada

Respondida
Looping through a matrix of unknown dimensions
For your case: start_matrix = rand(5,6,7,8,1000); nd = 1:ndims(start_matrix); a = permute(start_matrix,nd([end,1:end-1])); o...

casi 7 años hace | 0

Respondida
reading text file with multiple rows and columns
z = fopen('now1.txt'); c = textscan(z,'%s','delimiter','\n'); fclose(z); t = regexp(c{:}{3},'\w*(?=\[)','match'); n = regexp...

casi 7 años hace | 1

| aceptada

Respondida
cell array with mixed data types into single type
Let A - your cell array: out = cellfun(@double,A);

casi 7 años hace | 1

| aceptada

Respondida
Using matlab to evolute a simple vector , but not fit the inference
m = 4; n = 8; a = ones(m,n); a(1,6) = 5; for ii = 1:m-1 for jj = 2:n if a(ii,jj)>1 if ii == 1 ...

casi 7 años hace | 0

| aceptada

Respondida
How to select randomly 30 numbers from 108 and maintain uniqueness
randperm(108,30) or let A - your data array 108 x 1 aa = unique(A); out = aa(randperm(numel(aa),30));

casi 7 años hace | 1

| aceptada

Respondida
Create the matrix with some limits
kron(ones(1,10),1:2)

casi 7 años hace | 0

| aceptada

Respondida
index of an array multiple same element
[a1,~,ii] = unique(a,'stable'); out = [num2cell(a1(:)),accumarray(ii,(1:numel(ii))',[],@(x){sort(x)})];

casi 7 años hace | 0

Respondida
Merge arrays rows based on similarity in their serial number
A = [ 12345; 47542; 32673; 65436; 75343; 23496; 54765]; B = [23566; 33425; 65438; 75354]; [~,ii] = min(abs(A - B(:)...

casi 7 años hace | 1

| aceptada

Respondida
Cumulative sum per ID
T = readtable('now1.txt','HeaderLines',1,'ReadRowNames',0); T2 = varfun(@cumsum,T,'GroupingVariable',2,'InputVariables' ,3:7); ...

casi 7 años hace | 0

Respondida
Set zero in certain rows of an array to value x
A((A + [0;2;2]) == 2) = 1e6;

casi 7 años hace | 0

Respondida
How to create a matrix of coordinates
[ii,jj] = ndgrid(n:-1:1,1:n); out = cat(3,ii,jj);

casi 7 años hace | 1

Respondida
How can I convert a cell array into a double array
out = cell2mat(cellfun(@(x)cell2mat(cat(1,x{:})).',CellMatrix,'un',0));

casi 7 años hace | 1

| aceptada

Respondida
Checkin for equal values in the same column
T = array2table(A); m = varfun(@mean,T,'GroupingVariables',1); out = A; out(:,2:end) = out(:,2:end) - m{A(:,1),3:end};

casi 7 años hace | 0

| aceptada

Respondida
How to calculate sum of all the possible combinations of two vector elements
log(kron(exp(B),exp(A)))

casi 7 años hace | 1

| aceptada

Respondida
creating a nested loop to change values within a for loop
[ii,k,jj] = size(young_50); yy = permute(young_50,[2,3,1]); y1 = reshape(yy(:,[1,3:end],:),k,[]); b = squeeze(yy(:,2,:)); p ...

casi 7 años hace | 0

Respondida
find row with certain value and put in cell
z = B.*permute(A,[1,3,2]); [~,jj] = ndgrid(1:size(A,1)*2,1:size(A,2)); out = accumarray(jj(:),z(:),[],@(x){unique(x(x~=0))});

casi 7 años hace | 0

Respondida
How can I equate all values of one vector to another and get the value ? Please find the example below
dataA = [-496,-636,-52,175,-84,-248,-555,-423,34,-174]'; dataB = [-0.399609375000000,-0.512402343750000,-0.0418945312500000,......

casi 7 años hace | 0

| aceptada

Cargar más