Answered
Objective function for fmincon from surrogate model
Can't you just do, fun=@(X) norm(mdl.predict(X)-y).^2

3 years ago | 0

| accepted

Answered
Is it possible to add more constraints than the default ones in LSQLIN function?
You can still use lsqlin, but as John said, you can add additional inequality constraints as follows, Q=-sign(d).*C; r=zeros(s...

3 years ago | 1

| accepted

Answered
Optimising Limits of Chain integrals
There is virtually no benefit to the problem based approach if you are going to use fminunc. The main advantage of problem-base...

3 years ago | 0

Answered
Cross-correlation of two complex signals using sliding dot product
If there is to be no zero-padding, what should happen when the shorter signal slides to the edge of the longer signal? Does the ...

3 years ago | 0

| accepted

Answered
Finding Roots between a Differential and Piecewise Equation
a=1; [t_root,fval]=fzero(@(t)rootFcn(t,a), pi) function out=rootFcn(t,a) xp1 =@(t) ((-(8*2)/(2^2+1))*cos(t))+((8/(2^2+...

3 years ago | 0

| accepted

Answered
Effect of zero padding on FFT amplitude
Here is an example showing that the amplitude of an FFT does not change due to zero-padding. In all cases, the peak amplitude is...

3 years ago | 0

Answered
Projection using Modified Gram-Schmidt orthogonality
Aorth=orth(A); %A orthogonalized ProjB=Aorth*(Aorth.'*B); %projection of B

3 years ago | 0

| accepted

Answered
How to use conditional bounds for parameters with lsqcurvefit?
You must divide the problem into two cases: one case where X0 is fixed at 0 and the second when Y0 is fixed at zero. xdata = 0:...

3 years ago | 3

| accepted

Answered
When using JacobianMultiplyFcn in lsqnonlin, why is Jinfo required to be numeric? How can I pass more general kinds of parameters to my JacobianMultiplyFcn?
I seem to be have been able to fool lsqnonlin into doing what I want by using the attached classdef. However, I still wonder, ne...

3 years ago | 0

| accepted

Submitted


Tools for Processing Consecutive Repetitions in Vectors
A set of functions for labeling and manipulating groups of consecutively repeating elements in a vector.

3 years ago | 157 downloads |

5.0 / 5

Answered
How to group same value data
G=findgroups(A(:)); splitapply(@(x){x}, B(:),G)

3 years ago | 0

| accepted

Answered
Latex typesetting in Livescript
I have expressed a desire to have \label{} and \ref{} in LiveScript, https://www.mathworks.com/matlabcentral/answers/1723075-au...

3 years ago | 0

Answered
calculate the euclidean distance among all the pairs of nodes and use those resulting distances as the edges weights of the graph
This is already done in spatialgraph2d() https://www.mathworks.com/matlabcentral/fileexchange/73630-spatialgraph2d which I thi...

3 years ago | 0

| accepted

Answered
Cut off a Curve created by "curve fit"
This might be what you want: for i = 1:12 x1 = [emax(i); emid(i); 0]; y1 = [vmax(i); vmid(i); dvc(i)]; p = pol...

3 years ago | 0

Question


When using JacobianMultiplyFcn in lsqnonlin, why is Jinfo required to be numeric? How can I pass more general kinds of parameters to my JacobianMultiplyFcn?
What I would like to do is use the JacobianMultiplyFcn option of lsqnonlin's trust-region-reflective algorithm where Jinfo is a...

3 years ago | 1 answer | 0

1

answer

Answered
limiting broadcast variables in parfor loops
The block decomposition that you are doing needs more explanation. If the blocks are just fixed-sized, non-overlapping tiles of ...

3 years ago | 0

| accepted

Answered
how to run a function on GPU cores
so it would be great if we could have a function like "parfor" for GPU-based parallel processing. No, you cannot use GPU cores ...

3 years ago | 0

| accepted

Answered
MATLAB Problem. How to design matrix from eigenvalues
mindist=@(A) min(sqrt(pdist(real(A(:))).^2+pdist(imag(A(:))).^2)); n=5; Q=rand(n); Q(1)=0; Q=(1-eye(n)).*Q*0.5/mindist(...

3 years ago | 0

| accepted

Answered
MATLAB Problem. How to design matrix from eigenvalues
mindist=@(A) min(sqrt(pdist(real(A(:))).^2+pdist(imag(A(:))).^2)); n=5; P=rand(n); D=diag(rand(1,n)); A=P*D/P; A=A/mi...

3 years ago | 1

Answered
extract data points where the slope (derivative) of the plot changes suddenly
data=[ 1 2 3 4 3 2 1] loc=abs(diff(data,2)) > 1 loc=[false, loc ,false]; %pad with zeros because diff() shortens the vect...

3 years ago | 0

Answered
Extracting data points (with specific coordinates) from plot
For example, Y=40+0.04*linspace(-1,1,10) data=10*(1:numel(Y)) data_Extracted = data(abs(Y-40)<=0.01)

3 years ago | 0

Answered
Make loop more efficient
Simpler: A=rand(5), I=(A<0.5); A(I)=A(I)+1,

3 years ago | 0

| accepted

Answered
I am trying to replace the objective function of neural network to customised one
This talks about supplying a custom model function for NN training: https://www.mathworks.com/help/deeplearning/ug/train-networ...

3 years ago | 0

Answered
Use of fmincon with objective function as m-file
One way is to wrap the functions in an anonymous function: fun=@(X) objective_fn(V_exp, volt(O_plus,O_minus,X,L_a,L_c,I_app,t)...

3 years ago | 1

Answered
Fminsearch results shows shift from measured curve. How should I solve this?
The x_Start=[1,1] selection looks very arbitrary. If one of the parameters is the oscillation amplitude, it should be closer to ...

3 years ago | 0

Answered
Dividing each row in a 48X5120 int32 with the maximum value in the row
A=double(A); result = A./max(A,[],2)

3 years ago | 0

| accepted

Answered
Custom Matrix Interpolation for every 10 numbers in each column
A=reshape(1:40,[],2); A(10:end,:)=A(10:end,:)*2; A=A(1:5:end,:); %hypothetical input M=5; %upsampling factor A=kron(A...

3 years ago | 0

| accepted

Answered
latex in text doesn't work
gca; s=sprintf('$\\tilde{y}_x$ = %.3f',5) text(0.5, 0.5,s, ... 'Interpreter', 'LaTeX','fontsize', 30);

3 years ago | 0

Answered
Scaling in optimization problems
the derivate with dV/dc will get ever smaller with t. It's not clear that that matters because the values of c are also influe...

3 years ago | 0

| accepted

Answered
add constant value to row
A=readmatrix('yourFile.xlsx'); A(:,end+1)=600;

3 years ago | 0

Load more