Answered
I am having an array with positive integers, and i want to know all the possibility that the sum of elements of the array is close to or equal to a number say (N))
N=40; A = [1 7 13 20 38 39 40]; A=unique(A); n=find(cumsum(A)<=N,1,'last'); result=cell(n,1); for i=1:n tmp=su...

4 years ago | 0

| accepted

Answered
Fast way of computing all possible products of n matrices
This solution (note the attachments) does it in about 1 sec for a 20x20x10 set of single float matrices. matrices=rand(20,20,10...

4 years ago | 3

| accepted

Answered
Losing resolution after transformation using imwarp
load cameraParams im0=imread('b8-12212022142637-2006.Bmp'); [im_a, newOrigin] = undistortImage(im0, cameraParams); imagePoi...

4 years ago | 0

| accepted

Answered
axes object properties for 3D volumes?
I recommend this FEX download, https://www.mathworks.com/matlabcentral/fileexchange/22940-vol3d-v2?s_tid=ta_fx_results

4 years ago | 0

| accepted

Answered
Optimization stopped because the objective function cannot be decreased in the current search direction.
I found a few options 'DiffMaxChange' 'DiffMinChange' and 'FiniteDifferenceStepSize' potentially related, but not quite clear ho...

4 years ago | 1

Answered
Formulating Matrix in Linear Programing (Optimization problem)
You haven't explained which variables are your unknowns, and which are problem constants. Regardless, you do not have to build m...

4 years ago | 0

Answered
I got negative Lagrange Multipliers in linprog
I've changed my answer. I can't be completely sure, but it appears that your constraints have numerically unstable properties, t...

4 years ago | 0

| accepted

Answered
how to avoid for loop to increase speed
A=rand(91,1); % vector with 91 random samples B=[9,10,10,8,11,10,10,9,10,6]; % vector with the number of samples G=repelem...

4 years ago | 0

| accepted

Answered
parfor unable to classify, why?
I suspect it is because mycell is intended to be a sliced variable, but the code violates the fixed indexing rule, Fixed Index ...

4 years ago | 1

| accepted

Answered
eig() gives eigenvalues in the "wrong" order
eigenshuffle from this FEX post might be applicable, https://www.mathworks.com/matlabcentral/fileexchange/22885-eigenshuffle

4 years ago | 2

| accepted

Answered
How to caluclate centroid of a voronoi cell of a voronoi diagram.
The voronoi cells are always convex, so assuming it is bounded, you can just take the mean of all the vertices of each cell. X...

4 years ago | 1

| accepted

Answered
Unable to classify variable in body of parfor loop (cannot figure out how to resolve indexing)
See the rules for Sliced Variables. M=size(strategies,1); Species1by2 = zeros(M,M*12); parfor species1 = 1:length(strateg...

4 years ago | 0

| accepted

Answered
Expectation of inverse of complex Gaussian variables
So there must be some error that I couldn't find out and misunderstanding. The misunderstanding is that the expectation is infi...

4 years ago | 2

| accepted

Answered
Add value at new position automatically to matrix
A = [1 2 3;4 5 6]; C=[A, zeros(2,1); zeros(1,3) , 1 ] or C=blkdiag(A,1)

4 years ago | 1

| accepted

Answered
Rigidly translating and mirroring 2D coordinates
curve1 = importdata("curve1.txt"); curve1(:,3)=[]; curve2 = importdata("curve2.txt"); [ocurve1,ocurve2]=deal(curve1,curve2)...

4 years ago | 0

| accepted

Answered
Saving a resized image while keeping the resized values
Because with saveas, you are saving a screenshot of the figure window, not an image composed from the pixel values of resize_im...

4 years ago | 1

| accepted

Answered
Why I cannot get negative answer ?
x=0; y=2; if (x>=5) & (y>2) f=x^2-y; elseif (x<5) | (y>0 & y<=2) f = x-y^2; else (x<0 & x>0) & (y<0) f= x^...

4 years ago | 0

| accepted

Answered
How to remove edges around blank circle from a mask?
Using bwlalphaclose from this FEX download https://www.mathworks.com/matlabcentral/fileexchange/90762-further-tools-for-analyzi...

4 years ago | 1

Answered
Interp2 Function error using meshgrids
The problematic line is, rmax=1; This means that X,Y will mostly be located well outside the R,Z grid where they cannot be int...

4 years ago | 0

Answered
MATLAB crashes after loading 4000x4000x4000 matrix
Is the array sparse? If so, you might consider re-expressing it as a sparse data type using this FEX download: https://www.math...

4 years ago | 0

Answered
Why am I receiving this error?
Try deleting line 9 and retyping it.

4 years ago | 0

Answered
How to find the nearest gaussian of a function ?
Use fit(x,y,'gauss1') if you have the Curve Fitting Toolbox or this FEX download if you have the Optimization Toolbox, https:/...

4 years ago | 1

Answered
Creating a projection of a surface on a plane for area calculation.
Could someone please give me guidance on how to create a projection of the tetrahedron on the x-z plane? Just throw away the y-...

4 years ago | 0

Answered
How to determine corresponding points between two 3d coordinate systems?
Using this FEX download, https://www.mathworks.com/matlabcentral/fileexchange/26186-absolute-orientation-horn-s-method v1 = [...

4 years ago | 0

| accepted

Answered
Identify two coordinates on the X-axis and Y-axis of a 3D object
[x,y]=deal(data(:,1),data(:,2)); [~,xmin]=min(x); [~,xmax]=max(x); [~,ymin]=min(y); [~,ymax]=max(y); points = data([xmi...

4 years ago | 0

| accepted

Answered
Linprog => constraint that x1 and x2 are not allowed to be both unequal from zero
Assuming this is a 2D problem, as you seem to imply, you could solve under the assumption that x1=0 and then under the assumptio...

4 years ago | 0

Answered
How to change all elements of a vector V to achieve the condition sum(V) equal with a upper and lower boundaries?
V=[0.1 0.002 0.5 0.2 0.1 0.003 0.4]; lp=0.01; up=0.8; n=numel(V); V(:)=(1-n*lp)/n+lp sum(V) V>=lp V<=up

4 years ago | 1

Answered
Sort elements of Array by given condition
n=load('vector').xr; m=numel(n); n=n(randperm(m)); loc=find(([n ;0]-[0 ;n])>0); n(loc(68):end)=sort(n(loc(68):end),'de...

4 years ago | 1

| accepted

Answered
Passing variable in function instead of the actual literal number causes problems
Easier: n=int32(11); b = bitget(n,8:-1:1)

4 years ago | 1

Load more