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

4 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)

4 years ago | 0

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

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

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

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

4 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)

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

4 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);

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

4 years ago | 0

| accepted

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

4 years ago | 0

Answered
Minimize a variable in a no-linear system
If you use the Problem Based optimization tools, you can pretty much type in the problem as you have for us above, and the solve...

4 years ago | 0

| accepted

Answered
run takes too long!
i have this code that it runs and answers are correct but it takes so long...why?is there any solution? It is unnecessary to us...

4 years ago | 0

| accepted

Answered
How to rotate a 2D array (2D image) in 3D space around the x-axis?
A=rand(5) theta=90; R=eye(3); R(2:3,2:3) = [ cosd(theta) -sind(theta); ... sind(theta) cosd(theta)]; A=...

4 years ago | 0

Answered
How can I remove some specific rows in which zero an nan values exist?
load stations2 cutrows=stations2(:,2)==0|isnan(stations2(:,2)); stations2 stations2(cutrows,:)=[]

4 years ago | 0

| accepted

Answered
Question about matrix manipulation
Using this FEX download, it's fairly easy: https://www.mathworks.com/matlabcentral/fileexchange/115340-block-transposition-perm...

4 years ago | 0

| accepted

Answered
introducing a comparison related to variables in linear programming
The constraints you describe are non-convex, so there is no way to formulate them in a linear way. However, you can modify your ...

4 years ago | 0

| accepted

Answered
Neat enclosed area for a group of points on a plane
Your attached Data.mat looks like it contains different Data from your posted figure illustrations. load Data shp=alphaShape...

4 years ago | 1

| accepted

Answered
Minimize the Sum of Square error using optimization
I think you can do the whole optimization analytically. In particular, rewrite E as, where A and B...

4 years ago | 0

Answered
How to compare the the values of a 3-d dimensional array
n=find( 6000-100*t_span < E_lower,1); [~,kmin]=min(p(:,n,:),[],3);

4 years ago | 1

| accepted

Answered
How to Interpolate coordiantes and values of a surface plot
You can build a scatteredInterpolant object. Then you can interpolate anywhere you wish. load('mesh_coordinates.mat'); centr...

4 years ago | 0

Answered
Error in using lsqcurvefit with constrained parameters.
I think you can set the upper bounds equal to the lower bounds to fix the parameters as the OP in the previous post originally w...

4 years ago | 0

Answered
To find exponent in power law equation of the form y = ax^m + b
fminspleas downloadable from https://www.mathworks.com/matlabcentral/fileexchange/10093-fminspleas is especially appropriate...

4 years ago | 0

| accepted

Answered
To find exponent in power law equation of the form y = ax^m + b
If you have the Curve Fitting Toolbox, a = 0.55; m = 1.3; b = -0.78; % dummy data x = (1:25)'; y = a*x.^m + b + randn(si...

4 years ago | 0

Answered
Check Gradient (Jacobian) of objective function -- what is the meaning of absolute difference (1e-6) if component of gradient is less than 1 ?
If I know my values are so small (around 1e-7) per nature, a difference between 1e-7 and 2e-7 is significant. Not necessarily. ...

4 years ago | 0

| accepted

Answered
Removing semicolons from data
str = fileread('12h.json'); % dedicated for reading files as text  data = jsondecode(str); % Using the jsondecode function to...

4 years ago | 0

| accepted

Answered
Find distance from centroids to a specific point and remove objects that are having greater distance than the threshold
stat = regionprops(BW,'centroid','PixelIdxList'); ... CentroidDistances=pdist2(centroids,ECR); stat=stat(CentroidDistan...

4 years ago | 0

Answered
Draw circle in a rectangular
N=500; [x,y]=ndgrid(linspace(-10,10,N)); cmsk=x.^2+y.^2>=1; emsk=padarray(zeros(N-6),[3,3],1); [R,G,B]=deal(~cmsk&~em...

4 years ago | 0

Answered
Draw circle in a rectangular
s=([0 0 ; 0 1; 1 1; 1 0]-1/2)*20; t=linspace(0,360,1000)'; c=[cosd(t), sind(t)]; patch('XData',s(:,1),'YData',s(:,2),...

4 years ago | 0

| accepted

Load more