Answered
How to replace cell and neighbors that are zero in a matrix with nan
Perhaps as follows: A=[ 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 ...

5 years ago | 0

Answered
I have a system with 11 equations and 9 unknowns, how can I solve these equation sets?
See fsolve(), or if you want to put upper/lower bounds on the unknowns then see lsqnonlin().

5 years ago | 0

Answered
Apply the same matrix index to another matrix (bootstrap for matrix processes)
I want to apply to the second column of a matrix X (t=173;k=6)...I have tried data=X(2,indices) but it doesn't work You seem to...

5 years ago | 0

Answered
Large binned matrix reshape
tmp=num2cell(reshape(yourMatrix,200,10,10),[1,2]); result=vertcat(tmp{:});

5 years ago | 0

| accepted

Question


App property blocks with different attributes
I have an appdesigner app whose properties block looks like this: properties (Access = public) guiCanvas ...

5 years ago | 0 answers | 0

0

answers

Answered
fmincon optimize matrices of different size
x1=optimvar('x1',3,3); x2=optimvar('x2',4,4); fun = fcn2optimexpr( @(x1,x2) A1*(x1-A)^2*A1'+ B1*(x2-B)^2*B1' ,x1,x2) ...

5 years ago | 0

| accepted

Answered
Using vecnorm function as defined in a toolbox
Another solution might be to rename MNPBEM17\Misc\vecnorm.m to MNPBEM17\private\vecnorm.m This will only work, how...

5 years ago | 0

Answered
Using vecnorm function as defined in a toolbox
One solution I've found is to put vecnorm in a package directoy, e.g. +package/vecnorm. If you then import the version of vecno...

5 years ago | 0

Answered
Solving a set of nonlinear equations when fsolve or lsqnonlin are not able to solve
Well, each of your 3 equations represents an implict 3D surface and the solution x represents their intersection. You could use ...

5 years ago | 0

| accepted

Answered
Adding index to a function.
You could also have used a persistent variable. function allevents(src,evt) persistent accum if isempt...

5 years ago | 1

Answered
Adding index to a function.
One way is to nest the function inside an outerFunction() and make the accumulator an externally scoped variable. In the example...

5 years ago | 1

| accepted

Answered
Optimise multiple variables with "Division by an OptimizationVariable not supported"
c = [0.05; 0.1; 0.2; 0.4; 1]; obs = [3.947; 4.314; 4.171; 4.149; 4.109]; % Create a 3-D optimization variable named 'k'. k ...

5 years ago | 0

| accepted

Answered
How to average strings and numbers in the same table
load data T, Tmean=varfun(@mean, T,'Group',{'filename','Item Number'},'Input',{'X','Y'}); Tmean=Tmean(:,[1,4,5,2]); Tmea...

5 years ago | 0

Answered
Why do my plots end up empty?
If I make some guesses as to what operations you really intended, x = linspace(-2.5,2.5,10); y1 = x./(x.^2+1); y2 = (1/3)*(x....

5 years ago | 0

Answered
Using fsolve to solve equation system for coefficients of a Schwartz-Christoffel map
You cannot use complex-valued equations with fsolve, except under specific conditions, so your equations should really be set up...

5 years ago | 1

Answered
How to find second largest value and its index in an array?
A = [11,15,16,99,87]; [mx,ind]=maxk(A,2) secondMax=mx(2) index=ind(2)

5 years ago | 2

Answered
repeat vector elements and operate on them
A=[12; 10; 5]; B=[4;3;2]; C=repelem(A-1,B); T=ones(size(C)); I=B(1:end-1); T(cumsum(I)+1)=1-I; D=C+cumsum(T); D.'

5 years ago | 1

| accepted

Answered
Iterative evaluation of symbolic Jacobian matrix for multiple variable values for Newton Raphson model for nonlinear system of equation.
syms u1 u2 u3 u4 F1 = 0.5*u1^2 - 0.5*u1*u3 + 5.7e6; F2 = 0.625*u2^2 - 0.625*u2*u4 + 4.8e6; F3 = -0.5*u1*u3 + 2.75*u3^2 - ...

5 years ago | 0

| accepted

Answered
Matrix form for a square lattice arrangement.
For an arbitray lattice, you can always just use pdist2, D=pdist2(pts,pts,'cityblock'); H_tp=(D==1); This is without your c...

5 years ago | 0

| accepted

Answered
Matrix form for a square lattice arrangement.
If N^2 isn't too large, N=4; h_tb=sparse( toeplitz([0,1,zeros(1,N-3),1]) ); %1D A=kron(ones(N),h_tb); B=kron(h_tb,ones(...

5 years ago | 0

Answered
How to define constraint in Optimization such that difference in value between two consecutive unknowns is not greater than 50%
Here is a way to set up the constraint matrices using prob2matrices from, https://www.mathworks.com/matlabcentral/fileexchange/...

5 years ago | 0

Answered
Integrating the volume of a sphere using a step function as an integrand
You won't be able to get very good accuracy integrating a step function because of its discontinuity. It would be better if you ...

5 years ago | 0

| accepted

Answered
Sine function along inclined z axis
So, the problem is just adjusting the direction of the waves? If so, then perhaps as follows? row = 94; col = 195; h=10; the...

5 years ago | 0

Answered
Finding a maximum y value for each x values
G=findgroups(x); Maximums=splitapply(@max,y,G); Minimums=splitapply(@min,y,G);

5 years ago | 0

| accepted

Answered
Is there a faster or alternative way to use find()?
Br=round(B(:),3); Ar=round(A); [~,IDX]=ismember(Ar,Br);

5 years ago | 0

| accepted

Answered
Stop matlabFunction converting operators to element-wise operators
Perhaps as follows? syms x y; str = func2str( matlabFunction(mpower(x, y)) ); str(str=='.')=''; fh=str2func(str)

5 years ago | 0

Answered
Reading Multiple lines space separated data.
Use readmatrix() https://www.mathworks.com/help/matlab/ref/readmatrix.html

5 years ago | 0

| accepted

Answered
Linear programming with conditional constraints
Asume a bound e1<=M, and introduce additional binary variables b1 and b2 with the constraints. %(1) e1 <= M*b1; %This enforces...

5 years ago | 0

Answered
Make very small numbers in complex matrix zero
Is there a way to automatically ask matlab to output matrix like what's in the X_cleanup instead of X? No, but note that if you...

5 years ago | 0

Answered
Linear programming with conditional constraints
All the other constraints are regular linear expressions. If that's true then just divide the problem into two subproblems, one...

5 years ago | 1

Load more