Risposto
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)

quasi 4 anni fa | 0

Risposto
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...

quasi 4 anni fa | 0

Risposto
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...

quasi 4 anni fa | 0

| accettato

Risposto
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...

quasi 4 anni fa | 2

| accettato

Risposto
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...

quasi 4 anni fa | 0

Risposto
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...

quasi 4 anni fa | 0

| accettato

Risposto
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(...

quasi 4 anni fa | 1

Risposto
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).'

quasi 4 anni fa | 1

| accettato

Risposto
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...

quasi 4 anni fa | 0

| accettato

Risposto
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)

quasi 4 anni fa | 0

Risposto
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...

quasi 4 anni fa | 1

| accettato

Risposto
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...

quasi 4 anni fa | 0

Risposto
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)

quasi 4 anni fa | 0

Risposto
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...

quasi 4 anni fa | 0

| accettato

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

quasi 4 anni fa | 0

Risposto
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...

circa 4 anni fa | 0

| accettato

Risposto
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...

circa 4 anni fa | 0

| accettato

Risposto
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]

circa 4 anni fa | 1

| accettato

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

circa 4 anni fa | 0

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

circa 4 anni fa | 0

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

circa 4 anni fa | 0

Risposto
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),:)

circa 4 anni fa | 0

| accettato

Risposto
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))

circa 4 anni fa | 0

Risposto
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...

circa 4 anni fa | 0

| accettato

Risposto
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...

circa 4 anni fa | 0

| accettato

Risposto
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...

circa 4 anni fa | 0

Risposto
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...

circa 4 anni fa | 0

Domanda


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...

circa 4 anni fa | 1 risposta | 0

1

risposta

Risposto
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

circa 4 anni fa | 0

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

circa 4 anni fa | 0

| accettato

Carica altro