Answered
Problem with solving multivariable trigonometric equations
In order for solve() to find a solution, an exact analytical solution must exist.

5 years ago | 0

| accepted

Answered
fmincon converges to infeasible point
Well, your vlerror function which you are using as a nonlinear constraint function is completely independent of its input as you...

5 years ago | 0

| accepted

Answered
Avoid "for", "if" and "else" loop
D=(E_beta-Ev).^2-0.511^2; D( D<0 | ~Ev)=0; p=sqrt(D);

5 years ago | 0

| accepted

Answered
How to simplify factorial before calculating the result
nchoosek(2189,24)/nchoosek(2190,25),

5 years ago | 0

Answered
Find theta by cos(theta) and sin(theta).
theta=37; atan2d(sind(theta),cosd(theta))

5 years ago | 1

| accepted

Answered
Fastest (parallelized, maybe) way to run exponential fit function in a big matrix of data
Additional speed-up should also be possible by reducing your problem to a 1-variable estimation and removing subsref operations ...

5 years ago | 0

| accepted

Answered
Cost matrix from an array without for loop.
cost=abs( domain(:)-domain(:).' );

5 years ago | 1

Answered
Method invocation using dot notation error
The superclass defines a subsref method. Therefore, you must make an overloaded subsref method in your subclass mss to enable do...

5 years ago | 0

| accepted

Answered
How to calculate the binned average at the center of each X and Y grid points?
[N,~,~,binX,binY] = histcounts2(x,y,([-179.5:179.5], [-89.5:89.5]); zBinned = accumarray([binX,binY],z(:))./N;

5 years ago | 0

| accepted

Answered
Fastest (parallelized, maybe) way to run exponential fit function in a big matrix of data
If it's acceptable to you, a log-linear least squares fit can be done very fast and without loops A=Xax.^[0,1]; Bet=A\log(L...

5 years ago | 0

Answered
Optimisation: minimise function while maximising a design variable
Another approach would be to first minimize L with fmincon. [x0,L0]=fmincon(@(x) L(x),x00,____) %Problem (A) Then, maximiz...

5 years ago | 0

Answered
Determining if points lie within a sphere
Do you really need the indices? You can readily obtain a logical mask of the points in the sphere with, mask = (x-x0).^2+(y-y0)...

5 years ago | 0

| accepted

Answered
how to declare variable as constant without defining its value
It seems clear that they will only ever have common roots if d=0, in which case the common roots will be, syms x a b c solve(a...

5 years ago | 0

Answered
Write a script file that will compute the sine of an angle using the Taylor series formula:
Easier: n=10; x=pi/7; k=0:n; T=sum( ((-1).^k .* x.^(2*k+1))./factorial(2*k+1) ) approxError=T-sin(x)

5 years ago | 0

Answered
Why my Nonlinear function cannot be solved??
fun_y=@(y1,y2)y1.*8.0e+1+y2.*7.0e+1-log(y1)-log(y2); y1 = optimvar('y1'); y2 = optimvar('y2'); prob = optimproblem(...

5 years ago | 0

| accepted

Answered
Use of fminsearch in logscale
Well, that could make sense. On a log scale, much of your data could be either very far away from the central portion of the 3 G...

5 years ago | 0

Answered
Surface plot error for Z must be a matrix, not a scalar or vector
Just don't know how to make z a matrix after sph2cart z will be a matrix if at least one of the inputs f, theta and phi are mat...

5 years ago | 0

Answered
Why is my plot linear when the anonymous function z is clearly nonlinear?
It simply looks linear because you are plotting it over too narrow a range. Req = 0:120000; plot(Req,z(Req));

5 years ago | 2

| accepted

Answered
Transpose for double integral
To perform the double integral, f(x,y) needs to be calculated at all combinations of x(i) and y(j). The transpose makes x a colu...

5 years ago | 1

| accepted

Answered
How to load variables from Excel into Matlab workspace?
if you have many columns of data to load, you would not put them in separate workspace variables. You would just read them into ...

5 years ago | 1

Answered
Compute Volume of Cubic element from coordinate
One way: [~,volume(i)]=convhull( Coordinate(Element(i,:),:));

5 years ago | 0

Answered
Solve taking too long, how to optimize code?
Well, one solution is clearly, T1=T2=T3=T4=T5=(Tsurr-273) as you can verify by direct subsitution.

5 years ago | 0

Answered
How to plot the value of a matrix?
plot(yourMatrix)

5 years ago | 0

| accepted

Answered
what changes should i make in final optimised value with opt time vector
Use prob2struct s=prob2struct(prob); s.f0 The value of s.f0 will be the discrepancy between a problem-based linear optimizati...

5 years ago | 0

Answered
fminunc giving correct optimized values for anonymously defined function, BUT wrong value for .m function
At same initial values in two cases (anonymous function and .m function) the objective function gives same values which means th...

5 years ago | 0

| accepted

Answered
How do I create a matrix that has as values ​​the averages of variables found in loops?
If that's all you want to do, you shouldn't be saving the coordinates of the ROIs. You should just create a binary mask BW of ea...

5 years ago | 1

| accepted

Answered
How to assign a specific values to the nearest X,Y point
V=interp2(LON,LAT,SSP,X,Y,'nearest'); See also griddedInterpolant.

5 years ago | 0

Answered
I am trying to compute the zero of a function using fzero, but the system always says my function must be finite and real. How can I solve that? Thank you!
Clearly, your function is non-finite at x=0. There is a factor of x^2 in its denominator. Regardless, fzero() is the wrong too...

5 years ago | 0

| accepted

Answered
Loop in a cell array that consist of matrices in each cell
Easier: results=cat(3,results{:}); max_column = squeeze( max(results(2:end,12,:)) )

5 years ago | 0

Load more