Answered
How to return value to zero before index of specific element in matrix?
m=4;n=8; Matrix=rand(m,n), V=[3;7;2;5]; Matrix=Matrix.*((1:n)>=V),

4 years ago | 0

| accepted

Answered
Problem fitting with lsqcurvefit
Your model has 3 unknowns w(1), w(2), and w(3). However, you are only providing initial guesses x0 for 2 of these variables.

4 years ago | 1

Answered
find the corresponding x and y coordinates
i=100; x=-179:0.02:-175; y=10:0.02:20; [j,k]=ind2sub([numel(x),numel(y)], i); xi=x(j) yi=y(k)

4 years ago | 0

Answered
How do I plot this set as 3d region in matlab?
This will plot the hull for x=y=0; Looks pretty convex (as we knew it must be). x=0;y=0; fcn=@(u,v,z)x.^2+y.^2+u.^2+v.^2-z + 0...

4 years ago | 1

| accepted

Answered
Get array of elements based on occurrences of another vector
y=[0;1;2;3;4]; x=[1;1;2;2;2]; z=splitapply(@(x){x},y,x); z{:}

4 years ago | 1

Answered
nargout unavailable in anonymous functions when run from Live Script
Tech Support has classified it as "a bug in MATLAB Live Editor for 'nargout' function".

4 years ago | 1

| accepted

Question


nargout unavailable in anonymous functions when run from Live Script
The following code works fine at the command line and in mfile scripts. >>f=@()nargout >> f() ans = 0 >> a=f()...

4 years ago | 1 answer | 2

1

answer

Answered
Calculate the largest, smallest diameter and the centroid of a polyshape (irregula rpolygon) from a set of points
For the centroid, polyshape has a method centroid. If the min and max feret diameters are what you want, then one approach wou...

4 years ago | 0

| accepted

Answered
How to evenly distribute number of points in a non linear line made itself by number of points with different distances
See interparc: https://www.mathworks.com/matlabcentral/fileexchange/34874-interparc

4 years ago | 1

Answered
Mulitpling a scalar to specfic numbers in a vector
One way: [1 3 5 10 15 17 20 25 30].*repelem([2,5,10],3)

4 years ago | 1

| accepted

Answered
Newton iteration doesn't run smoothly
Possibly, you meant to have, if (abs(x-x0)) <= eps

4 years ago | 0

Answered
Nonlinear constraints not respected in optimization
Nonlinear constraints are only satisfied at convergence, and then only within the tolerance settings that you've specified. Yo...

4 years ago | 1

Answered
3d Matrix - Extract Subarray and Multiply by Conjugate Transpose without Forloops
[m,n,p]=size(A); Ar=reshape(A,[],p).'; UU = reshape(Ar,p,1,[]).*conj(reshape(Ar,1,p,[])); UU=reshape(UU,p,p,m,n); %obta...

4 years ago | 1

| accepted

Answered
What is the best and quick way to find the intersections points set of two 3d surfaces?
You can to download this FEX submission, https://www.mathworks.com/matlabcentral/fileexchange/74010-getcontourlinecoordinates?s...

4 years ago | 0

| accepted

Answered
Rotation of ellipsoid using matrix
You just compute the angle between one of the eigenvectors with the x or y axis.

4 years ago | 0

| accepted

Answered
Matrices with variable dimension
A=[1,0.1;0 1]; B=[0.005;0.1]; [n,m]=size(B); z=zeros(n,m); C=repmat({z},N+1,1); C{2}=B; for i=3:N+1 C{i}=A*C{i-1}; ...

4 years ago | 0

| accepted

Answered
How to do Double numerical integration with a variable limits
I'll demonstrate for a simpler function. The technique is the same regardless of what function we're integrating. F=@(x,y,z) x....

4 years ago | 0

| accepted

Answered
How to pass user-defined gradients for anonymous non-linear constraints in fmincon
I suspect you've misled yourself into believing the functions must be defined anonymously. I don't know of any situation where t...

4 years ago | 0

| accepted

Answered
Fitting Data to a Square root Cruve
k=sqrt(x(:))\y(:)

4 years ago | 2

| accepted

Answered
Subtracting two derivatives then store in a new function
Another possibility - numeric differntiation and integration. xFun = @(x,y) 3.*x.*y; dxFun = dfunx(xFun); yFun = @(x,y...

4 years ago | 0

Answered
Subtracting two derivatives then store in a new function
Another possibility- symbolic differntiation then symbolic integration: syms x y r theta xFun = 3.*x*y; dx = diff(xFun,...

4 years ago | 0

Answered
Subtracting two derivatives then store in a new function
One possibility - symbolic differntiation then numeric integration: syms x y r theta xFun = 3.*x*y; dx = diff(xFun,x); ...

4 years ago | 0

Answered
Improvement the speed of array filling
Furthermore , I have tried initializing X as a gpuArray() without any improvement. There should be some improvement. If there i...

4 years ago | 0

| accepted

Answered
How can I realize the 'ArrayValued' option in my customized function?
Use arrayfun.

4 years ago | 0

| accepted

Answered
imref2d error: Array indices must be positive integers or logical values.
You have hidden the size() command by creating avariable called "size". size = mean(brightradii)

4 years ago | 1

Answered
Creating string variables and paths to a directory
See fullfile.

4 years ago | 0

Answered
Bisection method while loop help
while (b-a)>tol

4 years ago | 0

| accepted

Answered
Running n instances of the same function simultaneously
You can use parfeval, assuming you have the Parallel Computing Toolbox.

4 years ago | 0

Answered
Split matrix into N Equal Parts by rows
If N is a multiple of 3, you can download blkReshape, https://www.mathworks.com/matlabcentral/fileexchange/115340-block-transpo...

4 years ago | 0

| accepted

Answered
Axes box incompletely copied to clipboard
export_fig from the File Exchange seems to be able to copy the figure gracefully to the clipboard. imagesc(ones);hax=gca; set(...

4 years ago | 0

Load more