Answered
How to find the corresponding position in a string
test_str=['a','b','c'] location = strfind(test_str,'c')

4 years ago | 0

Answered
How to find the corresponding position in a string
test_str={'a','b','c'}; [exists,location]=ismember('c',test_str)

4 years ago | 1

Answered
How to create vector which is linear combination of a matrix
Perhaps you instead meant to have, M = [1,2,3; 4,5,6; 7,8,9]; vec=M*[2;3;4]

4 years ago | 1

| accepted

Answered
Curve start and end coordinates
Gaussian curves are infinite in length., so it isn't clear what your criterion would be for where they start/stop. However, a go...

4 years ago | 0

Answered
Random Vector in decreasing order
There are alternatives to post-sorting, e.g. below, but no randomization function that will just spit out a sorted list. cumsum...

4 years ago | 0

| accepted

Answered
Problem of complex solution combining lsqnonlin solver with ode45
If you are getting complex solutions, it means that one of the calls to your objective function was given a real input, x, but r...

4 years ago | 0

| accepted

Answered
Parameter covariance from lsqnonlin when using Jacobian Multiply function?
Some people will compute just the diagonal D of J.'*J, approximating it as a diagonal matrix. This calculation is simply, D=sum...

4 years ago | 0

Answered
Genetic Algorithm + Parallel Computing + Global variables
Do you or anyone else have any other ideas for a workaround? It doesn't have to be the prettiest solution. You might be able to...

4 years ago | 0

Answered
How to limit function output range?
Use element-wise multiplication. u1 = @(t) t>=-4; u2 = @(t) t<=4; u3 = @(t) (u1(t) .* u2(t)); x1 = @(t) ((10 .* sin(pi*t/4))...

4 years ago | 1

Answered
How to limit function output range?
I would take a simpler approach: t = [-10:0.1:10]; x1 =10 * sin(pi*t/4).*(abs(t)<=4); plot(t,x1)

4 years ago | 1

Answered
Hessian in mlecov compared to hessian from fmincon
I was wondering if the hessian is estimated in mlecov in the same way as in fmincon? Probably, but even if not, the Hessian inv...

4 years ago | 0

Answered
Genetic Algorithm + Parallel Computing + Global variables
If you're using UseVectorized, it should be relatively easy. Within your parfor loop, store the results of processing each popul...

4 years ago | 1

Answered
Why won't my superclass method change my subclass object?
You need, obj=obj.addSdata; obj=obj.addRdata; Or, read about handle classes.

4 years ago | 0

| accepted

Answered
How do I add anonymous functions together?
Is this possible without converting the anonymous function to a string? I was hoping for something along these lines: for n = ...

4 years ago | 0

| accepted

Answered
How do I add anonymous functions together?
Trying to sum/concatenate anonymous functions is a bad thing to do, in general. Here is one way to accomplish it, however, fstr...

4 years ago | 1

Answered
Smart Indenting now Removes Whitespace
This is just my suspicion but, in the Matlab editor, the tab key doesn't really seem to insert tab characters. It appears just t...

4 years ago | 0

Answered
2d extrapolation to replace NaN in corners
One option is fillmissing. There are also offerings on the File Exchange, e.g., https://www.mathworks.com/matlabcentral/fileex...

4 years ago | 1

| accepted

Answered
Why does a for loop iterate over an empty column vector?
Yes, I'm sure it's expected. There will be as many iterations as there are columns of "bob". k=0; for bob=zeros(0,5) ...

4 years ago | 1

| accepted

Answered
how to multiply each elements of the cell with a scalar quantity?
OptP{i} =@(sigma) scalar * vpa(solve(rate_k(pt,sigma)==rate_th,pt));

4 years ago | 0

| accepted

Answered
fitting a customised guassian equation to the curve
Apply whatever Gaussian fitting routine you usually use to the scaled data (X/sqrt(2*log(2)), Y).

4 years ago | 0

| accepted

Answered
How to replace values in one matrix across a range of indices?
event=rand(15,1); index_mat = [4 8 10 12]; L=steps(index_mat(:,1),numel(event)); U=steps(index_mat(:,2),num...

4 years ago | 0

Answered
Interpolation of 3D arrays against a 1D vector
[Nx,Ny,~]=size(Data); F=griddedInterpolant({1:Nx,1:Ny,t},Data); Data_new=F({1:Nx,1:Ny,t_new});

4 years ago | 0

| accepted

Answered
How to remove elements of a positive array in a one-on-one-off manner?
Y = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

4 years ago | 0

| accepted

Answered
Circle projection to be ellipse on the ground
The final position of the projected ellipse will depend on the z-coordinates that you have before the rotation. z = 10*ones(1,l...

4 years ago | 0

Answered
Extract specific X & Y data from Contour curve
This has worked pretty well for me, https://www.mathworks.com/matlabcentral/fileexchange/74010-getcontourlinecoordinates?s_tid=...

4 years ago | 1

Answered
How to develop a ramp up of values into a matrix
n=100; PnC=50; SL=repelem(210,1,n); SL(1:PnC(1))=linspace(200,210,PnC(1)); plot(SL); axis padded

4 years ago | 0

| accepted

Answered
How to "automatically" show an equation, written in the matlab editor, as a text on a plot
Does the text have to be situated inside the plot? ezplot() will automatically create a plot title displaying the mathematical f...

4 years ago | 0

Answered
How to limit fsolve to find solution in Real numbers domain
That will automatically be the case, as long as the equation functions you have provided are real-valued.

4 years ago | 0

| accepted

Answered
How to fill missing grid value in 3D matrix
There is a command for that: fillmissing.

4 years ago | 1

| accepted

Answered
pause a program while running and resume from the same spot
Yes, there is a command for it: pause.

4 years ago | 0

Load more