Answered

Multiple sample values into scatteredInterpolant

What works is: Make a 3D array from B, so: for ih=1:length(B) B_3D(:,:,id) = B{ib) end And then add a vector 'h...

Multiple sample values into scatteredInterpolant

What works is: Make a 3D array from B, so: for ih=1:length(B) B_3D(:,:,id) = B{ib) end And then add a vector 'h...

2 months ago | 0

Answered

x undefined (Catenary Cable Case Study)

What you have done is programmed a function. So this function calculates fval when you give a value of x. You can now call this...

x undefined (Catenary Cable Case Study)

What you have done is programmed a function. So this function calculates fval when you give a value of x. You can now call this...

3 months ago | 1

| accepted

Answered

Locating point on x-axis where the slope is decreasing

Bascially you want to get the index when the change in theta becomes negative: dtheta = diff(theta); index = find(dtheta<0,1...

Locating point on x-axis where the slope is decreasing

Bascially you want to get the index when the change in theta becomes negative: dtheta = diff(theta); index = find(dtheta<0,1...

3 months ago | 0

Answered

Conversion to logical from sym is not possible.

g = 3; eff1=@(rr)-(1.8-0.8.*(1+rr)./(1-7.56.*g*rr))*rr/(0.01-0.11.*rr+0.06.*exp(23*rr)); x=fminbnd(eff1,-1,1); You could s...

Conversion to logical from sym is not possible.

g = 3; eff1=@(rr)-(1.8-0.8.*(1+rr)./(1-7.56.*g*rr))*rr/(0.01-0.11.*rr+0.06.*exp(23*rr)); x=fminbnd(eff1,-1,1); You could s...

3 months ago | 0

Answered

Hourly averages over a 20yr time series

Its not exactly clear over which values you want to calculate the mean, but have a look at this function, that can calculate mov...

Hourly averages over a 20yr time series

Its not exactly clear over which values you want to calculate the mean, but have a look at this function, that can calculate mov...

3 months ago | 0

Answered

Removing/clearing NaN/0 values from matrix/array data

A1 = A(A~=0 & B~=0) should work

Removing/clearing NaN/0 values from matrix/array data

A1 = A(A~=0 & B~=0) should work

3 months ago | 0

Question

1 iteration in fsolve: new x and no more

I want to use fsolve to only use one iteration: get the Jacobian, get x1 and done. However when test the code below, which tries...

3 months ago | 2 answers | 0

Answered

Optimization of system ODE

It is still not clear what your problem is. Do you get an error? Do you get a different solution than you expected? Anyway f...

Optimization of system ODE

It is still not clear what your problem is. Do you get an error? Do you get a different solution than you expected? Anyway f...

5 months ago | 1

Question

Why is EACH function evaluation inside a parfor loop much faster then ONE evaluation outside the loop?

Basically I calculate a finite difference Jacobian of a function, as shown below. The function evaluation labelled SINGLE RUN t...

5 months ago | 0 answers | 0

Question

Second Order optimality fmincon

Someone explained the second order condition for optimality of a constrained optimization problem here: https://math.stackexch...

2 years ago | 0 answers | 0

Question

Incorrect solution for symmetric problems in fmincon

If I maximize XX(1)^2+XX(2)^2 subject to x1 + x2 <=1 and use starting value X0=[0.5,0.5] I get as solution X=[0.5,0.5], although...

2 years ago | 1 answer | 0

Question

patternsearch with nonlinear equality constraint: any advice for more efficient steps?

Dear all, I have a constrained optimization problem which is not differentiable (because of some random errors), but it should ...

2 years ago | 0 answers | 0

Answered

How to normalize curves with multiple peaks such that each peak will be 1 and each valley will be 0?

Yeah, you would have to calculate a scaling factor for each peak/trough. In one dimension you can then use the scaling factor fo...

How to normalize curves with multiple peaks such that each peak will be 1 and each valley will be 0?

Yeah, you would have to calculate a scaling factor for each peak/trough. In one dimension you can then use the scaling factor fo...

2 years ago | 0

Answered

Tangent at a given point to a nonlinear curve

I think you need to be a bit more precise in what you want: you have data with errors in them, and you want to fit a curve that ...

Tangent at a given point to a nonlinear curve

I think you need to be a bit more precise in what you want: you have data with errors in them, and you want to fit a curve that ...

2 years ago | 0

| accepted

Answered

Matlab R2014A blurry on high-dpi windows device

Two things did it for me: 1. go to matlab/bin and right click application, choose compatibility and check "disable scaling on h...

Matlab R2014A blurry on high-dpi windows device

Two things did it for me: 1. go to matlab/bin and right click application, choose compatibility and check "disable scaling on h...

5 years ago | 0

Answered

fmincon and exitflag = -2 or 2 / non respect of constrained conditions

getting exit message 2 is not bad but if you insist on having 1, you could try to use smaller values for TolX (ie.. 1e-10 or eve...

fmincon and exitflag = -2 or 2 / non respect of constrained conditions

getting exit message 2 is not bad but if you insist on having 1, you could try to use smaller values for TolX (ie.. 1e-10 or eve...

6 years ago | 0

| accepted

Answered

Why does the first value in loop get overwritten

Thanks guys... normally i never save iteration variables like 'fi' but in this case the files contained "fi = 1". very silly

Why does the first value in loop get overwritten

Thanks guys... normally i never save iteration variables like 'fi' but in this case the files contained "fi = 1". very silly

8 years ago | 0

Question

Why does the first value in loop get overwritten

For some reason when fi == 1, NPV_list(1,1) is inserted correctly, but when fi=2 the value gets overwritten, which i dont unders...

8 years ago | 3 answers | 0

Answered

Vectorize sum of discount rates

thank you all for you answers... all did what i wanted, but the one by Matt Fig is the most simple

Vectorize sum of discount rates

thank you all for you answers... all did what i wanted, but the one by Matt Fig is the most simple

8 years ago | 0

Question

Vectorize sum of discount rates

Hi, I want to vectorize the calculation of series like this: [R^0;R^0+R^1;R^0+R^1+R^2;...etc. Im quite sure this should b...

8 years ago | 4 answers | 0

Answered

sum elements of matrix if...

It seems i can not edit my comment... so here again (sorry for mess, but i forgot to 'code' my code) Ok, i was not clear let ...

sum elements of matrix if...

It seems i can not edit my comment... so here again (sorry for mess, but i forgot to 'code' my code) Ok, i was not clear let ...

8 years ago | 0

Question

sum elements of matrix if...

Hi, lets say i have two matrices: A=rand(5,10); B=[ones(1,10);3*ones(1,10);ones(1,10);ones(1,10);3*ones(1,10)]; I...

8 years ago | 2 answers | 0

Answered

fixed-point iteration for root finding

a while loop might be a good idea: err_lim = 1e-6; x_new = %initial guess err = err_lim *2; %arbitrary to pass while ...

fixed-point iteration for root finding

a while loop might be a good idea: err_lim = 1e-6; x_new = %initial guess err = err_lim *2; %arbitrary to pass while ...

9 years ago | 0

Answered

how to solve a system of equations with n equation and m unknown (m>n)?

i think fmincon (constrained optimization) will work best... if you try to minimize some error use as the objective: objective=e...

how to solve a system of equations with n equation and m unknown (m>n)?

i think fmincon (constrained optimization) will work best... if you try to minimize some error use as the objective: objective=e...

9 years ago | 0

Answered

How to stop nonlinear fitting and obtain the results of fitting at that iteration

the display iter only displays something after an iteration is complete (after all function evaluations of that iteration are do...

How to stop nonlinear fitting and obtain the results of fitting at that iteration

the display iter only displays something after an iteration is complete (after all function evaluations of that iteration are do...

9 years ago | 0

Answered

How to stop nonlinear fitting and obtain the results of fitting at that iteration

im no expert on this (sorry) but did you try the 'output' function thingy... i know for most optimizers there is such a thing. i...

How to stop nonlinear fitting and obtain the results of fitting at that iteration

im no expert on this (sorry) but did you try the 'output' function thingy... i know for most optimizers there is such a thing. i...

9 years ago | 0

Answered

what is the optimal way to build a sparse matrix from row/col index, and value data?

did you check 'sparse'? i think this will do what you want: S = sparse(i,j,s) where i,j,s are your 3 column vectors... htt...

what is the optimal way to build a sparse matrix from row/col index, and value data?

did you check 'sparse'? i think this will do what you want: S = sparse(i,j,s) where i,j,s are your 3 column vectors... htt...

9 years ago | 0

| accepted

Answered

Optimization: Which algorithms I should choose when it's difficult to define an objective function?

...and if your problem is continuous, then the other optimizers are more usefull (fminsearch, fminunc, fsolve, fmincon,...). ...

Optimization: Which algorithms I should choose when it's difficult to define an objective function?

...and if your problem is continuous, then the other optimizers are more usefull (fminsearch, fminunc, fsolve, fmincon,...). ...

9 years ago | 0

Answered

how can i remove this error in matlab?

ermm, what error? and what do you actually want the line to achieve? i mean, the code wants to assign a matrix with blanks to co...

how can i remove this error in matlab?

ermm, what error? and what do you actually want the line to achieve? i mean, the code wants to assign a matrix with blanks to co...

9 years ago | 0

Question

Problem using 'deal' for objective and gradient in comb. with 'DerivativeCheck'

When using optimization tools I usually keep my objective function and gradient function as separate subfunctions and then use '...

9 years ago | 1 answer | 0