Random complete and in complete numbers
To randomize uniformly over an interval [lower, upper], you would do, out=rand(___)*(upper-lower)+lower

18 days ago | 0

| accepted

1D griddedInterpolant of a vector of query points.
One way: rows=1:2; gI= griddedInterpolant({rows,t},f); F=@(t)gI({rows,t}); >> F(3) ans = 0.1411 -0.9897 ...

18 days ago | 0

Filling a vector with ones based on a given value
B=(A(:)>=1:6)

18 days ago | 0

Submitted

spatialgraph2D
Creates a graph object with 2D spatial locations associated with the nodes

Z = [150:-1:1]; Nq = zeros(length(ADCP.t)); t=1:0.25:100; clear Ninterp for i=length(t):-1:1 time_in = tStart+...

19 days ago | 0

| accepted

Need to solve an singlevariable integral of functions of two variables, and get answers as functions
This function @(t) K_mex_p(t).*CC22(t,J) needs to return a numeric value for every given t. It is returning a symbolic value, ...

20 days ago | 0

Solving set of 5 non-linear simultaneous equations using fsolve
You should get rid of all the square roots on the unknown parameters. Write the equations in terms of new variables like z1=sqrt...

21 days ago | 1

Finding the standard deviation for every single value in a matrix
X=cat(3, X1,X2,X3,X4,X5,X6,X7,X8,X9,X10); %It was a mistake to create 10 separate matrices. MeansX=mean(X,3), StdX = std(X...

21 days ago | 0

| accepted

Solve functions symbolically, and getting answers as functions, solve() fsolve()
C_11_0 = matlabFunction( result.x ) ; C_12_0 = matlabFunction( result.y ) ;

21 days ago | 0

Intlinprog can not find feasible solution even though there is one
This version finds a solution. Basically, I pre-normalize max(Asen(:)) and max(a(:)) to 1 so that the constraint matrix elements...

22 days ago | 1

Intlinprog can not find feasible solution even though there is one
Aside from the error mentioned by Mario, the line A = [Atemp, -M*Atemp]; is overwriting your original A matrix (the one cont...

25 days ago | 0

How to put 2D image in 3D space
This FEX file looks applicable, https://www.mathworks.com/matlabcentral/fileexchange/28581-imsurf-3d-images

26 days ago | 0

fmincon constrain a row to be fixed
Yes, you can simply not treat them as unknowns. Instead, rewrite the problem in terms of a smaller matrix z containing the unkno...

30 days ago | 0

| accepted

Creating Multiple Arrays within a For Loop
You wouldn't do that with a loop. You would just use vector arithemtic, eps0=rand(3,1); %fake RHS data kappa=rand(3,1); z=ran...

1 month ago | 0

| accepted

Nonlinear Optimization problem ( If statement)
To do that, each x(i) must have finite upper and lower bounds L(i)<=x(i)<=U(i). You also need to introduce additional unknown b...

1 month ago | 0

| accepted

Most Efficient Way to Construct the Matrices to Extract the Lower and Upper Triangle from a Vectorized Matrix
Another approach to consider is to use my MatrixObj class https://www.mathworks.com/matlabcentral/fileexchange/26611-on-the-fly...

1 month ago | 1

Speed up Matrix multiplication
C=sum( A.*reshape(B,1,3,[]),2);

1 month ago | 1

| accepted

Equality contrains ignored by fmincon
You cannot use the Aeq, beq constraint parameters to force exact equality. You could instead try setting the upper and lower bou...

1 month ago | 0

Minimize function with multiple variables with absolute value
If e is positive, rewrite this as a linear program with additional unknowns ,

1 month ago | 0

how to generate a random array list with fixed sum ?
This FEX submission would be applicable https://www.mathworks.com/matlabcentral/fileexchange/9700-random-vectors-with-fixed-sum...

1 month ago | 0

How to get linprog to not ignore x0 R2019a
If your initial x0 is feasible, one way you might benefit from it is to add the inequality constraint f(:).'*x(:) <= f(:).'*x0 ...

1 month ago | 0

Variable distribution for a parallel image acquisition
Seems like you could use a parfor loop instead: parfor k=1:numel(img_temp) bw_seg_worker{k} = myWatershedFun(img_temp{k},...

1 month ago | 0

| accepted

How can I save my result in a loop when it is an matrix
Should the left hand side be S{i,j,k} ?

1 month ago | 0

improve and speed up parfor loop
We can't see all the operations in your loop, but the ones we can see are pretty basic ones. Operations as common and basic as t...

1 month ago | 0

Question

Union() operation adds hole to polyshape
I have attached a file containing a vector of 11 polyshape objects >> load('polyshape_vector.mat') >> whos pgon Name ...

1 month ago | 0 answers | 0

### 0

How to access GPU cores to execute parfor loop which has system commands?
I cannot use gpuarray method as there are no major computations done on a single matrix, but the data is passed using a single c...

1 month ago | 0

Update a value class property only if required
Is there a reason you don't update when changes to input1 or input2 occur, like in the following? classdef myclass prope...

1 month ago | 0

Would like to create a 2x3 matrix using for loop
This line has an error, iFlows=fio2o(i,2); The right hand side fio2o(i,2) is a scalar, but there is no indexing on the left ha...

1 month ago | 0

| accepted

Making a function to restructure matrix of coordinates
Z=reshape(xyz(:,3),6,6); %6x6 format and then to revert back, [X,Y]=ndgrid(1:6); xyz=[X(:),Y(:),Z(:)]; %36x3 format

1 month ago | 0

| accepted