Answered
how to solve singular matrix
It depends on the type of solution you are looking for. You can obtain the minimum norm solution using pinv, e.g., A=[2 0 0; 0 ...

6 years ago | 0

Answered
Decimal matrix to binary matrix correspond to each value of decimal matrix.
b=[0 0 1 ; 0 2 3]; reshape( string(dec2bin(b,6)),size(b,1),[])

6 years ago | 0

Answered
How to find the points where two lines cross?
T1=fzero(@GRdiff,[350,400]) T2=fzero(@GRdiff,[400,450]) function out=GRdiff(T) v = 1; V = 10; dHrxn = -80...

6 years ago | 1

| accepted

Answered
How to write nonlinear equation with several variables to use with bisection?
a = some value b = some value bisection(@(X) myFunction(a,b,X),Xl,Xr,iterations,tolerance)

6 years ago | 0

Answered
Newton's method for minimisation returns a critical point
Yes, it's normal.

6 years ago | 1

| accepted

Answered
return doesn't work within function
You cannot give a function the power to abort another function. See also, https://www.mathworks.com/matlabcentral/answers/57661...

6 years ago | 0

| accepted

Answered
curve fitting or optimisation toolbox
In terms of actual fitting, yes, the Optimization Toolbox can fit all the same functions, and more. However, the Curve Fitting T...

6 years ago | 0

| accepted

Answered
Plot images with iterative names as subplots
First you need to fix the way you read in the images. They should go into the elements of a cell array likse so, A{1}= imread('...

6 years ago | 0

| accepted

Answered
Fsolve stopped because problem appears regular
k=4; r=0.6; fnc = @(x1) [ r.*(1-(x1(1)./k)) ;x1(1)./(1+x1(1).^2)]; [xx,difference]=fzero(@(x1) diff(fnc(x1)), [-2,2]) fnc(...

6 years ago | 0

| accepted

Answered
How to find the max number in a structure array?
character(1).Name = ('Elora'); character(1).Skills = {'Hugs' 'Hyponosis'}; character(1).Lucky_Number = ('7'); character(1).Fa...

6 years ago | 0

| accepted

Answered
Robustly using ind2sub for problems with tunable dimensionality
n=4; dim=n*ones(1,n); A=ones(dim); % Here A is an n-cubic array filled only with 1 lin_ind=240; % I define a certain linear...

6 years ago | 0

| accepted

Answered
Inpolygon - wrong classification for points lcoated on boundary
If you represent the polygon using a polyshape object, P, you can use isinterior() in conjunction with polybuffer(), to add a to...

6 years ago | 1

Answered
use of built in functions; manipulating data arrays
The operation [2,3] is a matrix concatenation, which has only 1 output (the concatenated matrix). It is equivalent to making the...

6 years ago | 0

| accepted

Answered
Calculating the differences between XY pairs in a matrix
xy=M1(:,2:3); b=M1(:,4); A=xy(:,b==0); B=xy(:,b==1); tf = any(pdist2(A,B)<=5,2); result=A(tf,:);

6 years ago | 0

| accepted

Answered
Using Branch and Bound Algorithm to solve Discrete Binary Quadratic Programming (QP) problem
Can I use the branch and bound algorithm to solve my problem ((Discrete Binary Quadratic Programming (QP) problem)) in Matlab ...

6 years ago | 0

| accepted

Answered
Optimize an if loop
t=double(NL(:).'<=100); u=(movsum(t,[3,0])-t)>=3;

6 years ago | 0

| accepted

Answered
Optimize an if loop
u=[0,0,0, conv(double(NL(:).'<=100),[1,1,1],'valid')>=3];

6 years ago | 0

Answered
static optimization for muscles forces
The Optimization Toolbox has a number of different solvers that might be appropriate, depending on the form of your problem. SIn...

6 years ago | 1

| accepted

Answered
How to use fsolve to find constants after integration
syms x; syms c1; syms c2; expr = 2*x; F1 = (int(expr)+c1); F2 = (int(F1)+c2); fhandle = matlabFunction(subs([F1,F2],'x'...

6 years ago | 0

| accepted

Answered
division by zero problem
k = matlabFunction(de/no); [A,B,C] = meshgrid(-3:0.1:3); cur = k(A,B,C);

6 years ago | 0

| accepted

Answered
How can I check adjacent matrix values for a value?
I don't understand the rules of evolution of the board that you described. However, an efficient way to gather all the 8-neighbo...

6 years ago | 0

| accepted

Answered
Bisection method, Numerical analysis
a=0; b=1; m=(a+b)/2; while abs(y(m))>0.01 if y(a)*y(m)<0 b=m; elseif y(b)*y(m)<0 a=m; end m=(a+b)/2;...

6 years ago | 0

| accepted

Answered
Is slicing one big matrix more efficient than storing smaller matrices in a struct?
Therefore, with the former approach we would slice the matrix (via logical or a find) while in the latter we would just call all...

6 years ago | 0

| accepted

Answered
How can one pass arguments to a custom CrossoverFunction in ga?
The CrossoverFcn must accept 5 input arguments, options.CrossoverFcn = @(parents,options,nvars,FitnessFcn,unused,thisPopulation...

6 years ago | 0

| accepted

Answered
How to Split a 50000x2 data in .mat into 100 equal-sized 500x2 data?
One way is to use mat2tiles. For example A=rand(50000,2); Asplit=mat2tiles(A,[500,2]); whos A Asplit Name S...

6 years ago | 0

Answered
How to assign a vector on sub-digagonals of a N*N matrix in MATLAB?
See TOEPLITZ, https://www.mathworks.com/help/matlab/ref/toeplitz.html

6 years ago | 0

Answered
Does Mathworks offer any inbuilt support for Dynamic Programming?
Not built-in, but this File Exchange submission seems well-received, https://www.mathworks.com/matlabcentral/fileexchange/25786...

6 years ago | 0

Answered
Does Mathworks offer any inbuilt support for Dynamic Programming?
You could set up the dynamic program as the shortest path through a graph and use, https://www.mathworks.com/help/matlab/ref/gr...

6 years ago | 0

Answered
Find pixel intensity with coordinates?
pixelValues=yourImage( sub2ind(size(yourImage),X,Y) ); keep=(pixelValues>=threshold); X=X(keep); Y=Y(keep);

6 years ago | 0

| accepted

Answered
Finding elements of one vector that are closest to elements of another
D=abs(y(:)-x(:).'); result=sortrows( matchpairs(D,10*max(D(:))) ,1)

6 years ago | 1

| accepted

Load more