Respondida
How to generate all pairwise differences between two vectors
out = (a(:)' - b(:))./b(:)*100;

casi 7 años hace | 0

Respondida
convert cell to array
out = cat(1,A{:}); out = out(out ~= 0);

casi 7 años hace | 2

| aceptada

Respondida
How to find first non repeated (unique) character in a string?
z = 'hello'; [a,~,c] = unique(z,'stable'); out = a(find(accumarray(c,1) == 1,1));

casi 7 años hace | 1

Respondida
extract the 16 elements (4 by 4 matrix) from a big matrix
n = 4; s = size(A,1); out = reshape(A',s,n,[]); Here: out(:,:,1) -> B, out(:,:,2) -> C, out(:,:,3) -> D and etc.

casi 7 años hace | 0

Respondida
how to check symmetric for vector or array with 1 dimension
isequal(A(:),flip(A(:)));

casi 7 años hace | 2

| aceptada

Respondida
How to compare each element of a matrix with a number? And then star it out
a = [1 2 3 4 5 6 7]'; c = 6; lo = a >= c; z = ["","*"]'; out = a + z(lo+1);

alrededor de 7 años hace | 1

Respondida
How to generate all pairwise differences between two vectors
out = a(:) - b(:)';

alrededor de 7 años hace | 2

Respondida
Find common elements between two vectors and extract data from matrix (vectorized)
A3 = fix(A2.*(10.^-floor(log10(A2)))); [ii,~] = find(squeeze(all(A3==reshape(B,1,1,[])))); [~,~,c] = unique(ii,'stable'); jj ...

alrededor de 7 años hace | 0

| aceptada

Respondida
Matrix manipulation (matrix A to B format)
AA = [A,repmat([1,0],size(A,1),1)]; A3 = reshape(kron(AA,[1;1]),[],2,2); A3(2:2:end,:,:) = flip(A3(2:2:end,:,:),2).*[-1,1]; B...

alrededor de 7 años hace | 1

| aceptada

Respondida
Program that separates even and odd numbers and shows them in two vectors.
n = (1:100)'; lo = rem(n,2)==1; pares = n(~lo); impares = n(lo);

alrededor de 7 años hace | 1

| aceptada

Respondida
how to detect index of the max amplitude?
[out,ii] = max(A); out_ind = index(ii);

alrededor de 7 años hace | 1

| aceptada

Respondida
how to create this vector?
X=[0 0 0 1 1 1 1 0 0 1 1 0 0 0 1 1 1 1]; Y=[3 6 5]; Y2 = [0,Y]; out = Y2(bwlabel(X) + 1);

alrededor de 7 años hace | 1

| aceptada

Respondida
Scatter data interpolation of a column matrix
T = readtable('torque.xlsx','ReadV',0); torquei = xlsread('torquei.xlsx'); throttle= [0 2.5 5 10 15 20 30 40 50 60 65 70 75 80...

alrededor de 7 años hace | 0

| aceptada

Respondida
extract elements from four matrices and create new matrix
Let A,B,C,D - your matrix (4 x 4). out = reshepe(permute(cat(3,A,B,C,D),[3,1,2]),2,2,[]); or out = reshepe(permute(cat(3,A,B,...

alrededor de 7 años hace | 0

Respondida
Replace elements of a matrix
A = [1 4 3; 2 3 2;4 2 1;10,7,1]; b = [4 ,10 3 , 15 2 ,20 1 , 30]; [lo,ii] = ismember(A,b(:,1)); A(lo) = b(ii(lo),2); ...

alrededor de 7 años hace | 2

| aceptada

Respondida
How to linearly change values in matrix
toeplitz(1:-.1:.6) or 1 - abs((1:5) - (1:5)')*.1

alrededor de 7 años hace | 0

| aceptada

Respondida
How to merge a datetime array with a table
out = table2timetable(Result,'RowTimes',DT);

alrededor de 7 años hace | 1

| aceptada

Respondida
Element wise multiplication array-matrix between each element of the array with the whole matrix
result = kron(A(:),B)

alrededor de 7 años hace | 1

| aceptada

Respondida
How to chang matrix size 81x81x30 to 81x81x32 by add row
daily_avg_u(:,:,end + (1:2)) = zeros([size(daily_avg_u(:,:,1)),2]);

alrededor de 7 años hace | 1

| aceptada

Respondida
Averaging and summing parts of a column based on date
T = readtable('Matlab question.xlsx','Ra','A2:B109','ReadV',0); out = rowfun(@tempfun,T,'G','Var1',... 'OutputV',... ...

alrededor de 7 años hace | 0

Respondida
I am getting error in integrating a function from 0 to infinity wrt x. Kindly help.
Try q = integral(fun,0,Inf,'ArrayValued',1); but in your case the result is a zero vector, due to value of the gamma = 0.

alrededor de 7 años hace | 0

| aceptada

Respondida
grouped average in arrays
Old MATLAB T = table(A(:),repelem(string(['a':'d','b']'),[3,3,2,3,1]),'v',{'A','B'}); outT = varfun(@mean,T,'G',2);

alrededor de 7 años hace | 0

Respondida
Sum specific rows of an array
A = [0.2 2 3 1 3 4 1 4 6 0.8 4 6 2 5 1 1 6 2 0.4 6 2]; [a,~,c] = uniq...

alrededor de 7 años hace | 0

| aceptada

Respondida
comparing columns in matlab
out = A(all(A(:,1:2:end) ~= A(:,2:2:end),2),:)

alrededor de 7 años hace | 1

| aceptada

Respondida
find array in cell using cellfun
A = {[1,2,4],[2,3,4],[1,2,5]}; mes_in=[12,18,15,14,13]; B=[1 2;... 2 1;... 1 4;... 4 1;... 1 5;... 5...

alrededor de 7 años hace | 0

| aceptada

Respondida
Mean calculations in a for-loop
EDIT Let A is your vector with length n = 3192. i1 = 217; ii = 240; B = A; n = numel(A); lo = isnan(A); B(lo) = 0; p =...

alrededor de 7 años hace | 0

Respondida
Creating a matrix which has particular order of element ?
m = 6; n = 6; lo = triu(~rem((1:n)' + (1:m),2)); out = int64(lo); out(lo) = 1:nnz(lo); out = out'; with kron m = 7; n ...

alrededor de 7 años hace | 0

| aceptada

Respondida
Create a matrix of this type?
m = 8; n = 6; P = kron(triu(ones(n,m/2)),[1,1]); P(P>0) = 1:nnz(P); out = P';

alrededor de 7 años hace | 2

| aceptada

Respondida
find Euclidean distance without the for loop
distance12 = sqrt(sum(([centroid1,centroid2] - permute(dataset,[1,3,2])).^2,3));

alrededor de 7 años hace | 0

Cargar más