Answered
How manage for loop to calculate distances?
I should have a new "all_distances" variable with 5 values of distance, but it is only showing the error: Why 5 ? You should ha...

2 years ago | 0

Answered
runge kutta algae flower
Don't you have to call rk4 twice for stepsize h/2 to compare the results ? And shouldn't the Runge-Kutta step be pout = xk + (...

2 years ago | 0

| accepted

Answered
Find all possible combinations of numbers with a specific array length
M = categorical(["A","B","C","D"]); combinations(M,M,M,M,M,M,M,M,M,M,M,M)

2 years ago | 1

Answered
Finite method for a heat generating furnace
You use "j" twice as loop index in a nested loop. This will give problems. for j=1:Ny for i=1:Nx if i==Nx...

2 years ago | 0

| accepted

Answered
Not enough input arguments. Error in mypde_model>bcfun (line 53) ptop =utop - interp1(time, mydata(:,5), t,'spline'); Error in mypde_model (line 17) sol = pdepe(m, @pdefun,
Use sol = pdepe(m, @pdefun, @(z)icfun(z,u_ini1,u_ini2, Z),@(ztop, utop, zbot, ubot,t) bcfun(ztop, utop, zbot, ubot,t,time, myda...

2 years ago | 0

| accepted

Answered
Unable to find explicit solution.
You must use "dsolve", not "solve": syms t x(t) K eqn = diff(x,t) == (1-x/K)*x; dsolve(eqn)

2 years ago | 1

Answered
Doubt in Coupled Ode
Your code is correct, but it seems there is a singularity near 0.32.... syms t x(t) y(t) a1 b1 a2 b2 Constant eqn1 = diff(x,t,...

2 years ago | 0

| accepted

Answered
Solving a complex system of differential equations
%q(1) = X, q(2) = Y, q(3) = Xdot, q(4) = Ydot M = [1,0.8;0.8,7]; K = [5,0;0,10]; D = [0.15,0;0,0.35]; F = @(t)[5*exp(i*5*t);...

2 years ago | 0

| accepted

Answered
Piecewise function graph help
L=200; d=10; s=30; r1_max=22.36; r2_max=120.4; r=0:200; for i=1:length(r) if r(i) < d F(i)=0; elseif (r(i) >=d)...

2 years ago | 0

Answered
Why are complex values obtained for the below function (x) in the if condition?
Maybe you mean clc close all clear all a = 280; b = 580; c = 0.35; d =1.71E5; e = 7; f = 1+(3.5*(a/b)); g = d/(1+(0.00...

2 years ago | 1

Answered
me sale un error en la linea 67: " M(i,j)=buenos(val,3);" y el mensaje es: "Index in position 1 exceeds array bounds (must not exceed 120)"
Add the commands Ni*Nj size(buenos,1) after this line: %% Create output variable buenos = reshape([raw{:}],size(raw)); If ...

2 years ago | 0

Answered
Solving PDE and ODE coupled system with varying boundary conditions?
If you want to change a boundary condition, use a second function "fun" and call ode15s with the solution obtained so far and th...

2 years ago | 0

| accepted

Answered
2 second order differential equations with boundary conditions using bvp4c
Almost the same code as in the preceeding problem: % Parameters alpha = 0.001; gamma = 100; epsilon = 1; delta_v = 0.1; a=...

2 years ago | 1

Answered
Fitting two curves with shared parameters to two datasets
clc close all clear all set(0,'defaulttextinterpreter','latex') set(0,'defaultAxesTickLabelInterpreter','latex'); set(0,'de...

2 years ago | 0

| accepted

Answered
ODE15s Unable to meet integration tolerances without reducing the step size below the smallest value allowed
If you store P for 1:Nx and m for Nx+1:2*Nx, you should also return dPdt for 1:Nx and dmdt for Nx+1:2*Nx. But you return dPdt fo...

2 years ago | 1

Answered
Why is my multi-objective optimization with gamultobj (NSGA-II) not working?
Extract your optimization parameters at the time when the integrator returns NaN values. Are they reasonable ? If you think they...

2 years ago | 0

| accepted

Answered
Interior-point and sequential quadratic programming give me the same answer. Is there an error with my code?
I just saw in your code that you don't pass the options structure to fmincon. Thus in both calls, the same solver is used. Use ...

2 years ago | 0

| accepted

Answered
How to calculate first and second derivative for concentration?
It seems the concentrations are solutions of differential equations, thus something like dy/dt = f(y,t). So you can see that af...

2 years ago | 0

Answered
How can I get a loop within a loop to return a value as a matrix?
Maybe you mean B = -0.388; C = -0.026; P = 1.2; T = 305:5:550; R = 8.314; V9 = mvolume9(B,C,P,T,R); disp(V9) function ...

2 years ago | 0

Answered
Need Help With Function Creation and Integration
I'll assume that all variables except y0 are scalars and defined somewhere before in your code. In this case, use ua = integra...

2 years ago | 0

Answered
Solving a second order nonlinear differential equation with this boundary condition: y'(0) = 0, y(1) =1
The shooting method can be used for any combination of boundary conditions at x=0 and x=1. In your case, you have to estimate y...

2 years ago | 0

| accepted

Answered
1D Heat equation in Matlab with variable heat Flux at one side
You are doing numerics here. The maximum difference is 1e-13, I think this is acceptable: pdepeSolverTest() function pdepeSo...

2 years ago | 0

| accepted

Answered
Why am i getting blank plots
The solution for all four solution variables is NaN (see above) - most probably caused by the use of "log" in "theta_lm1" and "t...

2 years ago | 0

Answered
quadgk problems “Output of the function must be the same size as the input.”
Your functions cannot be vectorized for the below setup because they will be called with vectors for r, r_hat and theta of diffe...

2 years ago | 0

Answered
How do i fix my newtons method code?
fx and df are not function handles in your code. So you must use "subs" to evaluate them at a certain x-value. And setting x0 =...

2 years ago | 2

Answered
Symbolic function Gaussian Beam
w0 and z0 are function handles. You can't use them like variables in your definitions. Further, E is a complex-valued function....

2 years ago | 0

Answered
How to extrapolate the first 5 points
p = load("points.mat"); px = p.points(:,1); py = p.points(:,2); [~,idx] = sort(px); px = px(idx); py = py(idx); plot(px,py...

2 years ago | 0

Answered
How to perform recursive integration
syms a b x t positive syms F0 f(x) = b/a*(x/a)^(b-1)*exp(-(x/a)^b); F0(t) = 1; F1(t) = int(f(x)*F0(t-x),x,0,t) F2(t,x) = f(...

2 years ago | 0

Answered
Quadratic Objective with two Quadratic Constraints
What about function [y,yeq,grady,gradyeq] = quadconstr(x,B,C) y = []; yeq(1) = x.'*B*x - 1; yeq(2) = x.'*C*x - 1; i...

2 years ago | 1

Answered
Using Optimizing Nonlinear Functions to find mutiple variations
xdata=[125 127 129 131 133 135 137 139 141 143 145]; ydata=[0.002 0.003 0.009 0.025 0.053 0.089 0.104 0.09 0.07 0.041 0.017]; ...

2 years ago | 0

| accepted

Load more