Respondida
I have array and want to calculate mean every five element in this array and replace every five element by their mean value
A = 1:100 n = 5; Astair = repelem(mean(reshape(A,n,[]),1),1,n) plot(A) hold on plot(Astair)

casi 4 años hace | 0

Respondida
svd(X,"econ") does not work as expected if X is square nxn matrix with rank<n
You should read the doc again: "[___] = svd(A,"econ") produces an economy-size decomposition of A using either o...

casi 4 años hace | 0

Respondida
speed up for loop execution
Try this: T = reshape(temp2m_all_grids_avg, [], 1, 1); Tc = reshape(temp2m_all_grids_C_avg, [], 1, 1); hbins = reshape(elev_b...

casi 4 años hace | 0

| aceptada

Respondida
Sum: every nth column and groups/blocks of columns
c=3; % no. of countries s=4; % no. of sectors X=magic(c*s); % 12 XX = reshape(X,size(X,1),s,[]); S = sum(XX,3) C = squeez...

casi 4 años hace | 2

| aceptada

Respondida
slope of non linear
One of the most robust estimation of slope (in 2D) is using SVD % Fake data x = 10*rand(1,19); y = 2 + 3*x; x = x + 0.1*rand...

casi 4 años hace | 0

Respondida
How to use scatteredInterpolant in case of dimensions more than 3
Here is a linear scattered interpolation in any-dimension. It's bare calculation for a single query point, up to you to adapt f...

casi 4 años hace | 0

| aceptada

Respondida
How to transpose many matrices X_1 ... X_N at once?
This is the solution for the endless issues you are and will be enountered due of your naming variable with counter X_1 = rand(...

casi 4 años hace | 1

Respondida
array n x 3^n with all possible combinations of 0, 1 and -1
n=3; c=cell(1,n); [c{:}]=ndgrid(-1:1); c=reshape(cat(n+1,c{:}),[],n).'

casi 4 años hace | 1

| aceptada

Respondida
How to determine if matrix elements are incremented on a regular interval?
"timeStamp(m) + 0.2 == timeStamp(m+1)" You should never compare floating points with "==" rather threshold = 1e-10; if abs(t...

casi 4 años hace | 0

| aceptada

Respondida
GUI callback interrupts timer callback causing deadlock
Checkout parfeval that can be used run both tasks in parallel (I would put the log in background)

casi 4 años hace | 0

Respondida
How can I Perform bitxor operation in matrix?
A=[1 2 3 4], B=[11 22 33 44;3 4 5 6], C=zeros(max(size(A),size(B))) C(:,1:2:end)=bitxor(A(:,1:2:end),B(:,2:2:end)); C(:,2:2...

casi 4 años hace | 1

| aceptada

Respondida
Parfor loop classification "fix usage of indicated variable" error
Your code is good to be called "spagetti". If all the image have the same size, you must tell parfor what they are: jValues=1:2...

casi 4 años hace | 0

Respondida
How to generate a binary matrix with a fixed sum in rows and a changeable sum in columns?
A=kron(eye(5),ones(3,1)); A=A(randperm(end),randperm(end)) sum(A,1) sum(A,2)

casi 4 años hace | 0

Respondida
fminunc Converging at a strange point
@zhou caiwei "1. MATLAB has a variety of solutions, if one of them not work, try others until the prolem is solved; 2.MATLAB is...

casi 4 años hace | 0

| aceptada

Respondida
How can I get specified elements of matrix?
a(1:10:end)

casi 4 años hace | 0

Respondida
How do I modify/add data to a struct along specific field string values?
Try this: func = @(x) STR(x).numbers - STR([STR.type] == "other fruits").numbers isfruit = contains([STR.type], "fruits"); ne...

casi 4 años hace | 0

| aceptada

Respondida
Number of unique coordinates in an array
Is this what you want? n=4; d=3; c=cell(1,d); [c{:}]=ndgrid(1:n); relvnt=reshape(cat(d+1,c{:}),[],d); dm = d-sum(diff(sor...

casi 4 años hace | 0

| aceptada

Respondida
Nesting depth and the error "Expected one output from a curly brace or dot indexing expression, but there were x results."
a work around if you insist on oneline a(1).x.y=1 a(2).x.y=2 axy = [struct([a.x]).y]

casi 4 años hace | 1

| aceptada

Respondida
How to perform repmat function to repeat rows of a matrix
n = 2; kron(A,ones(n,1))

casi 4 años hace | 0

Respondida
How to perform repmat function to repeat rows of a matrix
n = 2; A(kron(1:end,ones(1,n)),:)

casi 4 años hace | 0

Respondida
How to perform repmat function to repeat rows of a matrix
n = 2; A(ceil((1:n*end)/n),:)

casi 4 años hace | 0

Respondida
How to perform repmat function to repeat rows of a matrix
A=[1,0,0,0,1;2,0,0,0,2;3,0,0,0,3] A(repmat(1:end,2,1),:)

casi 4 años hace | 0

| aceptada

Respondida
How to perform repmat function to repeat rows of a matrix
A=[1,0,0,0,1;2,0,0,0,2;3,0,0,0,3] reshape(repmat(reshape(A,1,1,[]),2,1,1),[],size(A,2))

casi 4 años hace | 0

Respondida
parfor and rng(1)
rdn(1) outside the parfor has no effect. from the doc: "For independent streams on the workers, use the default behavior or co...

casi 4 años hace | 0

| aceptada

Respondida
Problems in running for loop on keys on container maps
keySet = {'1,1', '1,2', '1,3'}; %use cell array valueSet = {[2 3], [3 4], [9,6]}; M = containers.Map(keySet,valueSet); for p...

casi 4 años hace | 0

| aceptada

Respondida
Parfor loop classification "fix usage of indicated variable" error
LEDdetectThresh=(mean(C_data_ArrayMean(:,:,idx),1))+C_data_ArrayStd(:,:,idx); LEDdurIndx=find(C_data_ArrayMean(:,:,idx)>LEDde...

casi 4 años hace | 0

Respondida
Vectorizing or otherwise accelerating nested loops with large multidimensional arrays
% Generate dummy data B=randi(4,10,3,5); A=rand(10,3,5); meanAmp = nan([max(B,[],'all'),size(A,2),size(A,3),size(A,3)]); f...

casi 4 años hace | 0

Pregunta


Why TMW does not improve INV?
If TMW thinks the legacy algorithm behind INV applied on full square matrix (base on LU and LDT) is not accurate enough (*), why...

casi 4 años hace | 1 respuesta | 0

1

respuesta

Respondida
Modify off diagonal elements of Matrix without looping
M = 4; A = rand(M); A(1:size(A,1)+1:end) = 10, % This is how you change the diagonal of A using linear indexing

casi 4 años hace | 0

Respondida
Sharing Variables between app and matlab workspace?
Put this statement after you generate your data in the callback mydata = ... assignin('base', 'mydata')

casi 4 años hace | 0

| aceptada

Cargar más