Code for solving first-order ode with symbolic initial condition
syms y(h) k ode = diff(y) == k*y; sol_ode_general = dsolve(ode) vars = symvar(sol_ode_general) eqn1 = subs(sol_ode_general,v...

5 days ago | 0

| accepted

How to convert PDE into matrix form
Can you write this in matrix form ? m1*diff(x1(t), t, t) + 0*m2*diff(x2(t), t, t) + (c1 + c2) * x1d - c2 * x2d + (k1 + k2) * x...

5 days ago | 0

Why do I receive the error in horzcat?
blkdiag(ddf(x), zeros(n)) is 2x2, A' is 1x1. Thus it's not possible to concatenate the two horizontally in the command H...

5 days ago | 0

Determine the coefficients in symbolic
I don't know why the coefficients appear in the wrong order. syms In In_1 On_1 On = 91/100*In-7/8*In_1+1/2*On_1; coeffs(On,[I...

6 days ago | 0

| accepted

how to solve non-linear equations in a nozzle
Maybe you can give better initial guesses in x0 for the solution than I can ... x0 = 10*rand(7,1); options = optimset('Max...

6 days ago | 1

| accepted

Solving Nonlinear System of Equations with 10 variables
W=100; s=10; S=23; %F=13; %m=9; fun = @(X1,X2,X3,X4,X5,X6,X7,X8,X9,X10)... [5-(W+S*9)*X1+S*9*X2-S*20*X1^2+S*20*X...

6 days ago | 0

calculating Double integral over a region
syms x y int(int(2,y,-sqrt(1-(x/3)^2),sqrt(1-(x/3)^2)),x,-3,3)

6 days ago | 1

| accepted

I am struggling to plot iteration vs error in the matlab code? can anyone help me with this? very much appreciate it.
% Inputs: A - Coefficient matrix A=[2 -1 0;-1 2 -1;0 -1 2]; % b - Input matrix b = [0; 2; 0]; % x0 - Initial guess x0 = [0...

7 days ago | 0

| accepted

Is it possible to get a time-dependent function as an output of an ODE solver?
clear all clc I0= 500; % maximum flow Tc=60/72; % heart period Ts=(2/5*Tc); % time in systole P_ss=80; % diastolic p...

7 days ago | 0

Error in the script
x = -1 : 0.001 : 1; y_div = (x.^2) ./ (1 + (x.^2)); title ('División acotada'); plot (x, y_div);

7 days ago | 0

Reverse problem of finding time-varying parameters of an ODE with the help of solution data.
Use "lsqcurvefit" to fit the parameters together with an integrator (e.g. ODE45). For an example, see Star Strider's code under...

7 days ago | 1

im trying to solve a system of 4 nonlinear equations with 4 unknowns
Equations (1), (3) and (4) give x(2) = 0. Thus it's impossible to satisfy equation (2) where x(2) is in the denominator. syms x...

7 days ago | 0

Corrective action after Newton iteration exception
I wonder if a similar corrrective action happens whenever a Newton-iteration exception occurs: in this case, does the solver sim...

7 days ago | 0

| accepted

The size of X must match the size of Z or the number of columns of Z.
Change dx = 1.01/(Nx-1); dy = 1.01/(Ny-1); to dx = 1.0/(Nx-1); dy = 1.0/(Ny-1);

7 days ago | 0

| accepted

Why should I tighten error tolerances if I am violating minimum stepsize?
The stepsize reduction down to the minimum stepsize often occurs because in previous time steps, the solver was not exact enough...

7 days ago | 0

| accepted

Num2cell question
Most probably too large for your computer: A = rand(12,3,5) A = num2cell(A)

7 days ago | 0

Matlab produces complex number where it cannot be produced
Because (Req.^3-b.*Req.^3)/(R.^3-b.*Req.^3) is negative. If you use k1 = 4; k2 = 1/3; P0=1.00*10^5; Req=69.2*10^(-3); b=...

7 days ago | 1

| accepted

Help with fminsearch to maximise non-analytic function via specific parameters
Here is the optimization solution: theta0 = 10; sol = fminsearch(@fun,theta0) function range = fun(theta) global rho d m g...

8 days ago | 0

| accepted

Why are the inputs to the functions used in the ODE45 solver not in the right syntax?
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %This is in thé main script: field = [1,0,1 ; 1,1,1]; %in my script ...

8 days ago | 0

| accepted

2nd order differential eqn for Windkessel model
I = @(t) I0*sin((pi*t)/Ts).^2.*(t<=Ts); %input current flow Idot = @(t) I0*2*sin(pi*t/Ts).*cos(pi*t/Ts)*pi/Ts.*(t<=Ts); Idotdo...

8 days ago | 0

| accepted

Help with fminsearch to maximise non-analytic function via specific parameters
Of course, you could use fminsearch for optimization. But using it, you will only get a single point of the below graph. Theta ...

8 days ago | 0

What type of solver is VPA Solve?

8 days ago | 1

"Error using indexing Not enough inputs to inline function; Error in NRM (line 93) INJAC=JAC(x1,x2)" showing in a multivariable Newton Raphson program.
For the 3-variable case, the line INJAC=JAC(x1,x2); has to be changed to INJAC=JAC(x1,x2,x3);

8 days ago | 0

Im trying to use gradient decent with a for loop to determine the value of x that minimizes the function
f = @(x) x.^2 - 3*x + 1; iterations = 15; alpha = 0.15; x = zeros(iterations,1); x(1) = 0; for...

8 days ago | 0

RK4 method to solve a 2nd ODE.
The definition of the function handles f1 and f2 is wrong: f1 = @(u,z,t) z0; % Initial f1 f2 = @(u,z,t) A*z0(t)+B*u0...

8 days ago | 1

the code is so slow , ode23, what can I do get it faster
B1 = [0.007664184 -2.9881 0.000406092 0.1383288248 10 0.0053322412 -3.048 0.0002825517 0.0714132532 12 0.0042969663 -3...

8 days ago | 0

| accepted

How to calculate u for every alpha?
... f= @(x)(0*zeros(size(x))); alpha = [2,5,10,15,20]; %lineare Basisfunktion A = assemDiffusion1D(nodes, epsilon); b = ass...

8 days ago | 0

| accepted

Using least square fitting function lsqr
rng(0) n = 20; s = rand(1, n) > 0.5; s = repmat(s', 1, 100)'; s = s(:)'; t = linspace(0, n, numel(s)); subplot(2, 1, 1) p...

8 days ago | 1

| accepted