Answered
Genetic Algorithm for points External To a Specific Volume
You would have to use a non-linear constraint function for that: function [cineq,ceq]=nonlcon(x) x=reshape(x,3,[]); %reshap...

4 years ago | 0

| accepted

Answered
How can I assign zeros to a particular value in an expression
N =8; u = [0,(1:N-1),0]; v=N:N-1+numel(u); rhsode=diff(u,2)+v(3:end)-v(1:end-2)

4 years ago | 0

Answered
Question about the fminsearch Algorithm
Is there a way for me to actually set up the starting simplex by myself? So that instead of giving the fminsearch-solver an init...

4 years ago | 0

Answered
Fitting a line of best fit on a plot only between a restricted domain.
You can do it interactively with the brush tool and basic fitting menu options on the figure toolbar. https://www.mathworks.com...

4 years ago | 0

Answered
Query regarding toolbar in MATLAB App designer
As far as I can tell, you must rebuild the toolbar using uitoolbar, uipushtool, and uitoggletool.

4 years ago | 0

| accepted

Answered
Parallel processing in ga using 'UseParallel'
Is it that it calls the objective function in parallel? Yes. And can I specify in the parallel pool settings that only 10 are...

4 years ago | 1

Answered
Automatisation of struct creation and data import
for i=1:3 data_alone_paired(i,1).acc_pelvis_subject1 = data_alone(2*i-1).fsignal_down(:,1); data_alone_paired(i,1).acc_pelvi...

4 years ago | 0

| accepted

Answered
How to calculate the rotation of this egg?
BW1=~getEgg('egg1.png'); BW2=~getEgg('egg2.png'); S1=regionprops(BW1,'Orientation'); S2=regionprops(BW2,'Orientation'); ...

4 years ago | 1

Answered
How to calculate the rotation of this egg?
First, crop the black corders from your image fiels. Then, use ellipticalFit() from, https://www.mathworks.com/matlabcentral/fi...

4 years ago | 1

Answered
How can I calculate and plot a 3D pointing vector from a 2D azimuth and elevation angle?
x1=2; %initial x position y1=2; %initial y position z1=0; elev=20; [az,r]=cart2pol(x1,y1); [x2,y2,z2]=sph2cart(az,elev*...

4 years ago | 0

| accepted

Answered
Not enough input arguments
It must be something in your environment. Running the code here in the forum produces no errors. I would suggest clearing the wo...

4 years ago | 0

| accepted

Answered
Deduplicate Rows from Struct
How about this? Database.x = [1 0 1 2 0 2 3 0 1 1 0 1]; Database.f = [10 20 ...

4 years ago | 0

| accepted

Question


Is there a way to specify objective and constraint gradients when doing nonlinear optimization in the problem-based framework?
In the solver-based framework, user-applied gradients are specified as additional output arguments from the objective and constr...

4 years ago | 1 answer | 0

1

answer

Answered
fmincon nonlinear inequality constraint
The nonlinear constraints are not obeyed at all iterations. At iterations where they are not obeyed, chol() will give you an err...

4 years ago | 2

| accepted

Answered
Remove centroid locations of objects that are too close
A=[xf(:) yf(:)]; D=pdist2(A,A); D(D==0)=inf; %retroactive EDIT keep = all(D>d,1); xf=xf(keep); yf=yf(keep);

4 years ago | 1

| accepted

Answered
Number of .mat files into single .mat file
It depends what they contain and how you want the variables joined within the final .mat file. One way: filenames="data"+(1:10...

4 years ago | 1

| accepted

Answered
Calibration) How can i get to know multiplying order of Rotation matrix corresponding each axis?
(1) There is no single, unique ordering of Rx,Ry,Rz when you decompose a rotation matrix. You have 6 different choices for the o...

4 years ago | 0

Answered
why is acumarray much slower calculating means than sum?
I suspect it is because, when you pass in @sum, accumarray is smart enough to recognize that it can use its default settings, wh...

4 years ago | 2

Answered
How to use lsqnonlin command for solving a cost function minimization problem which consists of optimization variable?
If you have an objective created with optimvar variables, you would solve the problem by using the solve command, C = [0 0 0 1 ...

4 years ago | 0

| accepted

Answered
limits of Optimization variable can be another variable in problem based optimization?
No, you must use a linear inequality constraint: PbattV1 = optimvar('PbattV1',N,'LowerBound',0); prob.Constraints.conName=(P...

4 years ago | 0

| accepted

Answered
How to convert an optimization variable to symbolic variable?
You can use the evaluate() command to substitute in values.

4 years ago | 0

Answered
Set elements in a 3D array to zero based on a condition
Qr=max(Qr,0);

4 years ago | 0

Answered
Set elements in a 3D array to zero based on a condition
Qr(Qr<0)=0;

4 years ago | 0

| accepted

Answered
reduction variables and evaluation order
First remember that each worker is assigned some consecutive subset of loop iterations. The worker will execute the iterations w...

4 years ago | 0

| accepted

Answered
max value of a function
In general I use: x= double(solve(diff(func))); This assumes there are no local min/max or saddle points. if i try to use max...

4 years ago | 1

| accepted

Answered
Fastest way to compute a multiplication of matrices times a sequence of kronecker products
With this FEX package https://www.mathworks.com/matlabcentral/fileexchange/25969-efficient-object-oriented-kronecker-product-ma...

4 years ago | 0

| accepted

Answered
for loop storing the same variable
Because in every pass through the loop, you assign the result to the same location. Perhaps you meant, demodulated_power_vector...

4 years ago | 0

| accepted

Answered
Error when using sptensor in parfor
You could try with ndSparse() instead of sptensor() https://www.mathworks.com/matlabcentral/fileexchange/29832-n-dimensional-sp...

4 years ago | 0

| accepted

Answered
Calculate the mean of nonzero pixels and setting a threshold
fun=@(z) nanmean(z(z<99)); my_mean = accumarray(double(mask(:))+1, my_array(:),[], fun)

4 years ago | 1

Load more