Réponse apportée
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)

presque 4 ans il y a | 0

Réponse apportée
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...

presque 4 ans il y a | 0

Réponse apportée
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...

presque 4 ans il y a | 0

| A accepté

Réponse apportée
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...

presque 4 ans il y a | 2

| A accepté

Réponse apportée
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...

presque 4 ans il y a | 0

Réponse apportée
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...

presque 4 ans il y a | 0

| A accepté

Réponse apportée
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(...

presque 4 ans il y a | 1

Réponse apportée
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).'

presque 4 ans il y a | 1

| A accepté

Réponse apportée
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...

presque 4 ans il y a | 0

| A accepté

Réponse apportée
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)

presque 4 ans il y a | 0

Réponse apportée
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...

presque 4 ans il y a | 1

| A accepté

Réponse apportée
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...

presque 4 ans il y a | 0

Réponse apportée
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)

presque 4 ans il y a | 0

Réponse apportée
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...

presque 4 ans il y a | 0

| A accepté

Réponse apportée
How can I get specified elements of matrix?
a(1:10:end)

presque 4 ans il y a | 0

Réponse apportée
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...

presque 4 ans il y a | 0

| A accepté

Réponse apportée
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...

presque 4 ans il y a | 0

| A accepté

Réponse apportée
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]

presque 4 ans il y a | 1

| A accepté

Réponse apportée
How to perform repmat function to repeat rows of a matrix
n = 2; kron(A,ones(n,1))

presque 4 ans il y a | 0

Réponse apportée
How to perform repmat function to repeat rows of a matrix
n = 2; A(kron(1:end,ones(1,n)),:)

presque 4 ans il y a | 0

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

presque 4 ans il y a | 0

Réponse apportée
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),:)

presque 4 ans il y a | 0

| A accepté

Réponse apportée
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))

presque 4 ans il y a | 0

Réponse apportée
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...

presque 4 ans il y a | 0

| A accepté

Réponse apportée
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...

presque 4 ans il y a | 0

| A accepté

Réponse apportée
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...

presque 4 ans il y a | 0

Réponse apportée
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...

presque 4 ans il y a | 0

Question


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

presque 4 ans il y a | 1 réponse | 0

1

réponse

Réponse apportée
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

presque 4 ans il y a | 0

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

presque 4 ans il y a | 0

| A accepté

Charger plus