Answered
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)

3 years ago | 1

| accepted

Answered
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...

3 years ago | 0

| accepted

Answered
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...

3 years ago | 0

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

3 years ago | 0

Answered
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...

3 years ago | 1

Answered
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...

3 years ago | 0

Answered
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...

3 years ago | 0

| accepted

Answered
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);

3 years ago | 0

| accepted

Answered
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...

3 years ago | 0

| accepted

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

3 years ago | 0

Answered
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=...

3 years ago | 1

| accepted

Answered
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...

3 years ago | 0

| accepted

Answered
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 ...

3 years ago | 0

| accepted

Answered
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...

3 years ago | 0

| accepted

Answered
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 ...

3 years ago | 0

Answered
What type of solver is VPA Solve?
https://de.mathworks.com/matlabcentral/answers/298048-which-algorithm-does-vpasolve-use

3 years ago | 1

Answered
"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);

3 years ago | 0

Answered
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...

3 years ago | 0

Answered
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...

3 years ago | 1

Answered
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...

3 years ago | 0

| accepted

Answered
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...

3 years ago | 0

| accepted

Answered
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...

3 years ago | 1

| accepted

Answered
Code optimization by way of selective computations
Ts = 1e-7; t = 0:Ts:1-Ts; tic s_t = exp(1i*2*pi*t(1:2:end)); toc or if your condition is more complicated: tic s_t = exp(1...

3 years ago | 0

Answered
how to combine to get single graph in optimal control problems
Use "hold on" and "hold off" to plot several graphs in one figure: f = @(x) x.^2; g = @(x)sqrt(x); x = 0:0.01:1; hold on pl...

3 years ago | 0

Answered
How to get numerical answers for solving determinant is 0
This is a generalized eigenvalue problem. Use "eig" to solve for p: E = 210 * 10^9; k1 = zeros(8, 8); k2 = zeros(8, 8); k1(1...

3 years ago | 0

| accepted

Answered
How to Call a Function Within a Script?
You have two options: Either define your derivatives in a function: [t,y] = ode15s(@vdp1000,[0 3000],[2 0]); plot(t,y(:,1),'-...

3 years ago | 0

| accepted

Answered
I'am trying to find minimum cost spanning tree by using Kruskal's algorithm and get these errors
nodes = unique([nodes; mst(ismember(mst(:,1),nodes),2)]); nodes is 1x2, mst(ismember(mst(:,1),nodes),2) is 1x1, Thus concatenat...

3 years ago | 0

| accepted

Answered
Need help converting equation into matlab code.
cp = c1*(c2./u - c3*beta - c4).*exp(-c5./u) + c6*lambda; instead of cp = c1.*(c2./u)-(c3.*beta-c4).*(exp(-c5./u))+(c6.*lambda)...

3 years ago | 1

| accepted

Answered
Writing a solver for DAEs with Runge-Kutta method
It seems that your DAE solver solves the third equation as a differential equation, not as an algebraic equation (see below). c...

3 years ago | 1

Answered
Incorrect values when calculating the optimum value using while loop
With regards to for loop, I used it to be able to do j-1 as a previous step But the steps (variable i) are done in the while lo...

3 years ago | 0

| accepted

Load more