Answered
Select nearest non zero value in column
b = [0; 0; 0; 2; 0; 0; 0; 0; 0; 3; 0] nearestfun = @(b) interp1(find(b),b(b~=0),(1:length(b))','nearest','extrap'); ...

7 years ago | 2

| accepted

Answered
apply a different condition to 2 columns
Example from you attached mfile >> a = [... 0.4317 0.9203 0.0155 0.0527 0.9841 0.7...

7 years ago | 2

| accepted

Answered
command for extracting data??
'end' when used in array indexing is replaced by |size(x1,n)|, where |n| is the dimension where the 'end' appears. Here in yo...

7 years ago | 0

Answered
I have a problem with LU
The four and five-output syntax are only applicable for *sparse* input matrix. You can try by converting your dense matrix to...

7 years ago | 0

| accepted

Answered
I have an array with 5 numbers, I want to concatenate it with another array with the same 5 numbers in a different order that do not correspond to the original.
What you need is the so called <https://fr.mathworks.com/matlabcentral/fileexchange/30189-randpermfull derangement>, a permuta...

7 years ago | 0

| accepted

Answered
How to change this matrix for expected matrix?
rot90(A,2)

7 years ago | 2

Answered
Looking for a more elegant (less process-time consuming) code that obviates the external for loops.
% order everything as 8D array as following % (x,y1,z1,z2,z3,t1,t2,t3) MM = permute(M,[1 2 5 3 4 ...

7 years ago | 0

| accepted

Answered
how I can find the edges of polygon given by voronoin used for 3D vertices in matlab??
From the doc: [V,C] = voronoin(X) returns Voronoi vertices V and the Voronoi cells C of the Voronoi diagram of X. C{k} ...

7 years ago | 0

Answered
please help simplify this for-loop-hell
data = {ceil(20*rand(100,6)) ceil(20*rand(50,6)) ceil(10*rand(20,6))}; biggest_data_series = randperm(15)'; biggest_...

7 years ago | 0

| accepted

Answered
How can I solve a Ax=b using lsqnonlin with constraints (x(1)>x(2)>...>x(6)>x(7))?
You can transform the constraint x(1) >= x(2) >= ... >= x(n) By changing variables y(1) = x(1) y(2) = x(2)-x(1) .....

7 years ago | 1

Answered
finding 2D curvature for a left ventricular plot
The original code is here: <https://fr.mathworks.com/matlabcentral/fileexchange/32696-2d-line-curvature-and-normals FEX excha...

7 years ago | 0

Answered
Determine the index of the value closest to the mean value of each group
Exactly as with my previous answer, but adapted for OP's test data read from Excel [~,~,C] = xlsread('MLdata.xlsx'); T...

7 years ago | 0

| accepted

Answered
How to pull specific data from solution set?
What prevent you to use bdipuniodefun() to compute the velocity dW/dt from |T| and |W| ?

7 years ago | 1

| accepted

Answered
How To Vectorize a For loop
Min=min(X)*(1-1e-6); %A little smaller than Minmimum value of X Max=max(X)*(1+1e-6); %A little bigger than Maximum value of...

7 years ago | 0

| accepted

Answered
Efficient way to apply fsolve to large 2D array element
It looks like you solve for pixel position of some distorded images, and you has a model for a distorsion. If you approximate...

7 years ago | 0

| accepted

Answered
Determine the index of the value closest to the mean value of each group
ntests = 1000; TC = ceil(10*rand(ntests,1)); R = rand(ntests,1); % Here is the n x 2 input matrix A = [TC, R]; ...

7 years ago | 0

Answered
How to create pairwise comparison matrix for row matrix?
Replace |==| with whatever comparison operator that is suitable for you C = a == a.' Edit, seem like you want (this...

7 years ago | 0

Answered
How to find the number of occurrences of each pair in a matrix?
A = [1 2 3; 2 3 1; 2 1 3]; u = unique(A); P = nchoosek(u,2); P = [P;fliplr(P)]; [~,J] = ism...

7 years ago | 0

| accepted

Answered
What is wrong with: [betta;delta;gamma]=inv([ab ab_cd -cd])*[C-A];
You cannot capture elements of array on the lhs directly to variables, you have to split it: x = inv([ab ab_cd -cd])*[C-A];...

7 years ago | 1

| accepted

Answered
How to find the mean of one column based on the value in another column
You command is correct (beside using 8th column instead of 2nd) *BUT*: Don't name your (output) variable MEAN, you will have ...

7 years ago | 1

| accepted

Answered
How to make all values before first non zero element in a matrix 1?
Assuming A is your matrix flipud(cumsum(flipud(A)))

7 years ago | 0

| accepted

Answered
Could anyone help me to solve the issue
set(gca,'xtick',(34:2:40))

7 years ago | 0

| accepted

Answered
How can i count the occurences of each element in a list of matrices?
XXXL = cat(1,X{:}); u = unique(XXXL(:)); n = histcounts(XXXL(:), [u,;inf]); bar(u,n) If you have memory issue,...

7 years ago | 0

Answered
How can I add constraints in a solution of a function?
n = 6; L = randn(n); S = L'*L; y = randn(n,1); rft = randn(1,1); su = 2; sl = -1; % T = V*V' T = S...

7 years ago | 0

| accepted

Answered
Replace groups of numbers in a matrix checking connections in 8-directions
What you need is a labeling algorithm. If your don't have Image Processing toolbox, there are several in FEX for example this <h...

7 years ago | 0

Answered
the polyarea function gives the wrong area
I think MATLAB result is right, your expectation is wrong. Check area >> 0.1807*0.4258-(0.1807-2*0.009)*(0.4258-2*0.00...

7 years ago | 0

| accepted

Answered
Standard deviation along 2 axes
D3 = rand(3, 51, 8) std(reshape(permute(D3,[1 3 2]),[],size(D3,2)))

7 years ago | 2

| accepted

Answered
Solving for a matrix
> K = [7 -8 1 0 0 0 0; -8 16 -8 0 0 0 0; 1 -8 14 -8 1 0 0; 0 0 -8 16 -8 0 0; 0 0 1 -8 14 -8 1; 0 0 0 0 -8 16 -8; 0 0 0 0 1 -...

7 years ago | 1

Answered
Could anyone help me to solve the issue in the following code
Adapt the <https://fr.mathworks.com/matlabcentral/answers/426511-could-anyone-help-me-to-solve-the-issue#answer_343806 answer th...

7 years ago | 0

Answered
Fast concolution of image and ellipse of varid sizes
You might try this <https://mathworks.com/matlabcentral/fileexchange/24504-fft-based-convolution FEX> file.

7 years ago | 0

Load more