Answered
Mean of matrix elements that have same value in the first column
[G, ID]=findgroups( dmRe_40(:,1) ); dmRe_40=[ID, splitapply(@(z) mean(z,1) , dmRe_40(:,2:7), G)];

4 years ago | 0

Answered
Limiting the sensitivity of initial guess in NLS Optimization/lsqnonlin/fmincon
For every fixed choice of c4,c5,c6 your optimization problem reduces to a linearly constrained least squares sub-problem, solvab...

4 years ago | 0

| accepted

Answered
How to define if a point is inside or outside a 3D pyramidal area?
Download this FEX submission, https://www.mathworks.com/matlabcentral/fileexchange/30892-analyze-n-dimensional-convex-polyhedra...

4 years ago | 1

Answered
How to define if a point is inside or outside a 3D pyramidal area?
Just camera project the point(s) onto the plane of A,B,C,D and use inpolygon to see if it lies between them. If the plane of AB...

4 years ago | 1

Answered
Mean value of a certain number range
vector=rand(1,100)*4+22.01; subset=vector>22.93 & vector<24.76; mean(vector(subset))

4 years ago | 0

| accepted

Answered
Best tool to calculate the parameters of a custom equation fit
For your particular equation, I'd rcommend, [a,b,c]=deal(3,2,1) x=linspace(1,2,30); %fake data y=a+b./x.^2.*exp(-x/c); ...

4 years ago | 1

| accepted

Answered
create a sparse multidimensional matrix
n=3; A=kron(speye(n),[0;0;1;0]) full(A)

4 years ago | 0

Answered
To find intersection point of two lines ?
How do you solve a special case when the slope is 0, Inf or –Inf? Use linexlines2D (Download) which doesn't make any assumption...

4 years ago | 0

Answered
How to add user defined function as constraint for optimization?
Ultimately, you must use the solver-based approach, like Torsten says. However, if you download this, https://www.mathworks.com...

4 years ago | 0

| accepted

Answered
Finding number(s) that is(are) repeated consecutively most often
Using, https://www.mathworks.com/matlabcentral/fileexchange/78008-tools-for-processing-consecutive-repetitions-in-vectors >> ...

4 years ago | 0

Answered
Finding Coefficients to Construct a Vector Using Defined Basis
Make the basis vectors the columns of a matrix A and then use mldivide, coefficients=A\b Here b is the column vector you are t...

4 years ago | 1

| accepted

Answered
How to avoid using det, when looking for the complex root w with det(M(w)) = 0
Because your matrix appears to be symmetric, I suggest minimizing instead norm(M(w)) which is the maximum absolute eigenvalue of...

4 years ago | 0

Answered
Optimisation functions: Skipping iterations if objective function returns an error or cannot run completely
Basically, the option available to you is to return inf from your objective when an error condition is reached. Some optimizatio...

4 years ago | 1

| accepted

Answered
fill a vector (efficiently) with values specified by matrix and multiple vectors
M=reshape(1:8,2,2,2);N=10; x=(rand(N,1)>0.5)+1;y=(rand(N,1)>0.1)+1;z=(rand(N,1)>0.1)+1; OUT=M( sub2ind(size(M),x,y,z) ...

4 years ago | 1

| accepted

Answered
Interpolating points in a 3D space with one line
You can use linear3dFit() from this FEX submission https://www.mathworks.com/matlabcentral/fileexchange/87584-object-oriented-t...

4 years ago | 1

Answered
how to handle soft weight constraints in neural network
If you wish to train with standard unconstrained stochastic gradient descent algorithms, you will probably have to make a custom...

4 years ago | 0

| accepted

Answered
Convert decimal and negative values ​​to integers
Something like this, perhaps? a = 0:pi/100:2*pi; x=cos(a); y = sin(x); fcn=@(z)round(rescale(z,0,intmax('uint16'))); pl...

4 years ago | 0

Answered
why do we need to flip kernel before using conv2 in CNN?
The field of neural networks uses the term "convolution" loosely. There are other differences as well. We also know that in trad...

4 years ago | 0

Answered
Applying the Nonlinear Least Squares Method to Minimize the Objective Function to Find the Parameters of the Equation
Your code makes strange assumptions about the output syntax of lsqnonlin. [x,resnorm,residual,exitflag,output,lambda,jacobian] ...

4 years ago | 0

| accepted

Answered
Trying to solve a matrix with four equations and four unknowns. Should be three non zero terms.
You cannot paste a function definition into the command window. Put it in a file and run it in the Maltab editor. Also, you are ...

4 years ago | 0

| accepted

Answered
How I can separate the data points by line?
You could use fitclinear. To illustrate, I will use fabricated data: %synthetic data N=500; Resistivity=rand(N,1); Porosity=...

4 years ago | 0

| accepted

Answered
Create a sliding window
matrix=reshape(vector,5e5,[]) This gives a matrix whose i-th window is matrix(:,i). How best to process that, though, depends o...

4 years ago | 0

Answered
A*1 and A+0 could be faster.
My sense of things is that, in the situations where you would care about such special case optimizations, you would know in adva...

4 years ago | 1

| accepted

Answered
Add dimensions to a matrix
[RHSval,kprimeind] = max(RHSvec,[],2,'linear'); kdpolind(act,kprimeind)= vector_that_is_51x1

4 years ago | 0

Answered
Why do I receive the array indices must be positive intergers or logical values
You haven't provided the input necessary to run your code, but it looks like tempo_fix-60 could be <=0.

4 years ago | 0

Answered
Calculate the value of an area around a known co-ordinate
mean(Thermal(y-1:y+1,x-1:x+1),'all')

4 years ago | 0

| accepted

Answered
Interpolation of the values of points on the surface created by convex hull
For example, was the question targeted at sampling new points on the surface...? Assuming that's the correct interpretation, th...

4 years ago | 0

Answered
how to range data and find maximum value for each range by using loop
AB=[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; 10 5 7 8 3 18 20 3 6 66 2 14 39 40 4 20].'; [maxval,i]=max(reshape(AB(:,2),4,[]),...

4 years ago | 0

| accepted

Answered
Generate Field Names from Variables While Accessing Elements of a Nonscalar Structure Array
Why not a 2D struct array, R(nDriver,1).LapData(nLap).LapTime R(nDriver,2).LapData(nLap).LapTime R(nDriver,3).LapData(n...

4 years ago | 0

Answered
How to find the index of a particular child when using use parallel = True option in genetic algorithm optimizer?
If you have the Parallel Computing Toolbox, set UseParallel=false and UseVectorized=true. Then, inside your objective function a...

4 years ago | 1

| accepted

Load more