Answered

How can I skip the rest of an if statement?

Also in for-loops, "break" only exits the inner structure, but the outer loop runs until the end (see below). Thus you cannot ...

How can I skip the rest of an if statement?

Also in for-loops, "break" only exits the inner structure, but the outer loop runs until the end (see below). Thus you cannot ...

9 days ago | 0

Answered

Surface plot doesn't correspond to optimization solution

The problem is now, when I select a point randomly in the surface plot, and then calibrate the model for these values, I do not ...

Surface plot doesn't correspond to optimization solution

The problem is now, when I select a point randomly in the surface plot, and then calibrate the model for these values, I do not ...

9 days ago | 0

| accepted

Answered

Solving an equation with symbolic matrix

https://uk.mathworks.com/matlabcentral/answers/1918100-error-using-solve-with-symmatrix-equation

Solving an equation with symbolic matrix

https://uk.mathworks.com/matlabcentral/answers/1918100-error-using-solve-with-symmatrix-equation

10 days ago | 1

Answered

A group of 12 people all roll a pair of dice 12 times, how often does each person roll a total number that is greater than or equal to 7?

In my opinion, it should be roll1=randi(6,12); roll2=randi(6,12); total=roll1+roll2; GT7 = total>=7; totalGT7 = sum(GT7,1);...

A group of 12 people all roll a pair of dice 12 times, how often does each person roll a total number that is greater than or equal to 7?

In my opinion, it should be roll1=randi(6,12); roll2=randi(6,12); total=roll1+roll2; GT7 = total>=7; totalGT7 = sum(GT7,1);...

10 days ago | 1

| accepted

Answered

error in for loop

u(j-3) is only defined for j>=4, u(j+3) is only defined for j<=length(R)-3. Similar restrictions hold for the other indices. Thu...

error in for loop

u(j-3) is only defined for j>=4, u(j+3) is only defined for j<=length(R)-3. Similar restrictions hold for the other indices. Thu...

10 days ago | 0

Answered

I'm suppose to plot the response of the system but i'm getting wrong values

alpha is a constant , and this is the value of it , I doubt that the rate of change at t=0 for x(5) should be 2.55e17 as you g...

I'm suppose to plot the response of the system but i'm getting wrong values

alpha is a constant , and this is the value of it , I doubt that the rate of change at t=0 for x(5) should be 2.55e17 as you g...

11 days ago | 0

Answered

How can I multiply a row vector with each of two column vectors?

t = [1 2]; s = [(1:3)',(4:6)']; kron(t,s)

How can I multiply a row vector with each of two column vectors?

t = [1 2]; s = [(1:3)',(4:6)']; kron(t,s)

11 days ago | 3

Answered

final value of x in PDE

i want to solve this equation for r at given time and concentration I assume that the time for which you want to get r is in th...

final value of x in PDE

i want to solve this equation for r at given time and concentration I assume that the time for which you want to get r is in th...

12 days ago | 0

Answered

How to prevent substrate concentration going below minimum limit in fed batch fermentation model.

You can use the "Events" option of the ode integrators to interrupt and restart integration with different settings if a certain...

How to prevent substrate concentration going below minimum limit in fed batch fermentation model.

You can use the "Events" option of the ode integrators to interrupt and restart integration with different settings if a certain...

12 days ago | 0

| accepted

Answered

How can I ensure that the initial solution (x0) for fsolve does not result in Inf or NaN values?

You know your "external_fun" best. Try to deduce in advance which inputs will lead to failure. Maybe you can use "lsqnonlin" ins...

How can I ensure that the initial solution (x0) for fsolve does not result in Inf or NaN values?

You know your "external_fun" best. Try to deduce in advance which inputs will lead to failure. Maybe you can use "lsqnonlin" ins...

13 days ago | 0

Answered

Huge minimum value from expected results

I cannot run this code because it takes too long or maybe the matrix exponential cannot be computed analytically. Does it give ...

Huge minimum value from expected results

I cannot run this code because it takes too long or maybe the matrix exponential cannot be computed analytically. Does it give ...

13 days ago | 0

| accepted

Answered

ODE45 solver returning constant value as the input variable.

As you can see when you run the below code, p is in the order of 1e12 which makes dL/dt effectivly 0. Check your units. %Def...

ODE45 solver returning constant value as the input variable.

As you can see when you run the below code, p is in the order of 1e12 which makes dL/dt effectivly 0. Check your units. %Def...

13 days ago | 1

| accepted

Answered

The code does not converge

I seems your function does not vary much with rho. The evaluation cannot find a value for rho for which the function has a zero....

The code does not converge

I seems your function does not vary much with rho. The evaluation cannot find a value for rho for which the function has a zero....

13 days ago | 0

| accepted

Answered

How to plot the error of two numerical methods on the same graph?

%% Given data f=@(x) 8-4.5*(x-sin(x)); df=@(x) -4.5*(1-cos(x)); x0=1; tol=0.0001; n=50; [x_newton,i_newton,Error_newton]=n...

How to plot the error of two numerical methods on the same graph?

%% Given data f=@(x) 8-4.5*(x-sin(x)); df=@(x) -4.5*(1-cos(x)); x0=1; tol=0.0001; n=50; [x_newton,i_newton,Error_newton]=n...

13 days ago | 1

Answered

Modifying the objective function in order to meet the optimization variable boundaries

if (A <= 1e-04) & (A >= 4e-04) How can A be <= 1e-4 and >= 4e-4 at the same time ? And if-statements have to be done elementwi...

Modifying the objective function in order to meet the optimization variable boundaries

if (A <= 1e-04) & (A >= 4e-04) How can A be <= 1e-4 and >= 4e-4 at the same time ? And if-statements have to be done elementwi...

14 days ago | 0

Answered

Solve a matrix equation

D = eig(A) will give you the values for D for which det(A-DI)=0

Solve a matrix equation

D = eig(A) will give you the values for D for which det(A-DI)=0

14 days ago | 0

| accepted

Answered

Solving goal programming problem with MATLAB

x0 must be a vector of size 1x5, not 1x4. Further, your function must return a vector of length 4, not 3. Further, the first o...

Solving goal programming problem with MATLAB

x0 must be a vector of size 1x5, not 1x4. Further, your function must return a vector of length 4, not 3. Further, the first o...

15 days ago | 0

Answered

plot() and fplot() give different results for the same function

x = linspace(0, 100, 10000); y = 2*sqrt(1+x)+sin(sqrt(pi)*x).*sin(sqrt(1+x)*pi).*(2*x+1)./sqrt(x) - 2*sqrt(1+x).*cos(sqrt(x)*pi...

plot() and fplot() give different results for the same function

x = linspace(0, 100, 10000); y = 2*sqrt(1+x)+sin(sqrt(pi)*x).*sin(sqrt(1+x)*pi).*(2*x+1)./sqrt(x) - 2*sqrt(1+x).*cos(sqrt(x)*pi...

15 days ago | 0

Answered

Vpasolve can not find a solution that I know it exist

Maybe it must read Eq2 = ((a21*W2)/(c2*(a21+a22))) - x12 == 0; instead of Eq2 = ((a12*W2)/(c2*(a21+a22))) - x12 == 0; ? c...

Vpasolve can not find a solution that I know it exist

Maybe it must read Eq2 = ((a21*W2)/(c2*(a21+a22))) - x12 == 0; instead of Eq2 = ((a12*W2)/(c2*(a21+a22))) - x12 == 0; ? c...

15 days ago | 0

| accepted

Answered

How to build a graph of the solution of a second-order differential equation in MATLAB

Since sin(pi) = 0, your differential equation reduces to y'' + y = 0 with general solution a*sin(t) + b*cos(t) Now incorpor...

How to build a graph of the solution of a second-order differential equation in MATLAB

Since sin(pi) = 0, your differential equation reduces to y'' + y = 0 with general solution a*sin(t) + b*cos(t) Now incorpor...

15 days ago | 1

Answered

"Busy" when running this code with ODE45

Use ode15s instead of ode45 - you have a stiff system of differential equations.

"Busy" when running this code with ODE45

Use ode15s instead of ode45 - you have a stiff system of differential equations.

16 days ago | 0

Answered

How to solve complex equations?

Your equation has only complex solutions. Note that you used sind instead of sin in the function definition. Thus assuming the...

How to solve complex equations?

Your equation has only complex solutions. Note that you used sind instead of sin in the function definition. Thus assuming the...

17 days ago | 1

| accepted

Answered

how to output quantities involving time derivatives in pdepe

You don't have access to the spatial discretization of pdepe, thus no access to the exact time derivatives. But if you choose th...

how to output quantities involving time derivatives in pdepe

You don't have access to the spatial discretization of pdepe, thus no access to the exact time derivatives. But if you choose th...

17 days ago | 0

| accepted

Answered

lsqcurvefit claiming complex-valued function

Although the fiting function fit_function is the log of a real valued part of the function, why is it considering that the funct...

lsqcurvefit claiming complex-valued function

Although the fiting function fit_function is the log of a real valued part of the function, why is it considering that the funct...

17 days ago | 0

Answered

How to test whether a function has roots within a given range?

F = @(x) sin(x); xmin = 0; xmax = 6*pi; x = linspace(xmin,xmax); Fx = F(x); I = find(diff(sign(Fx))) F(x(I)) F(x(I+1))

How to test whether a function has roots within a given range?

F = @(x) sin(x); xmin = 0; xmax = 6*pi; x = linspace(xmin,xmax); Fx = F(x); I = find(diff(sign(Fx))) F(x(I)) F(x(I+1))

17 days ago | 0

| accepted

Answered

how to output quantities within pdefun, bcfun, icfun in pdepe

After pdepe has finished, call "heatcyl" at the output times. x = linspace(0,1,25); t = linspace(0,1,25); m = 1; sol = pdepe...

how to output quantities within pdefun, bcfun, icfun in pdepe

After pdepe has finished, call "heatcyl" at the output times. x = linspace(0,1,25); t = linspace(0,1,25); m = 1; sol = pdepe...

17 days ago | 2

| accepted

Answered

user defined function including a for loop taking vector input giving vector output

p = 10; result = myfunc2(p) function [y2]=myfunc2(p) y2 = zeros(1,p); y2(1) = 1; for t=1:p-1 y2(t+1)=y2(t)+t; ...

user defined function including a for loop taking vector input giving vector output

p = 10; result = myfunc2(p) function [y2]=myfunc2(p) y2 = zeros(1,p); y2(1) = 1; for t=1:p-1 y2(t+1)=y2(t)+t; ...

18 days ago | 1

Answered

how to input variable with set of value to the PDE

The x-interval of integration was missing, and your boundary condition at x = xl would not work. Further, I changed the T-vector...

how to input variable with set of value to the PDE

The x-interval of integration was missing, and your boundary condition at x = xl would not work. Further, I changed the T-vector...

18 days ago | 0

Answered

what's the relation between A , B and M,G for this Nonlinear system of equation ?

A^2 + B^2 - 2*A*B*cos(2*Phi) = G^2 + M^2

what's the relation between A , B and M,G for this Nonlinear system of equation ?

A^2 + B^2 - 2*A*B*cos(2*Phi) = G^2 + M^2

19 days ago | 1

| accepted

Answered

Why Dsolve considers my equations' variables constants!?

syms t x1(t) x2(t) p1(t) p2(t) eq = [diff(x1, t) == x2, diff(x2, t) == - p2 - x2, diff(p1, t) == 0, diff(p2, t) == p2 - p1] ds...

Why Dsolve considers my equations' variables constants!?

syms t x1(t) x2(t) p1(t) p2(t) eq = [diff(x1, t) == x2, diff(x2, t) == - p2 - x2, diff(p1, t) == 0, diff(p2, t) == p2 - p1] ds...

19 days ago | 0

| accepted