Answered
If statement should continue for some values even if "else" is true
You must have a flag which indicates whether the engine is on or off. function [w,T] = EnginePower(B_SoC) persistent on ...

4 years ago | 0

Answered
Make a loop with a function to vary one value
tspan = [0 :0.01:20]; y0 = 0; opt = odeset('RelTol',1e-12,'AbsTol',1e-16,'MaxStep',0.001); Eta = [10, 50, 100, 500, 1000]; f...

4 years ago | 0

| accepted

Answered
Verify the Divergence theorem in MATLAB
Nice exercise. syms X Y Z x y z syms a phi positive F = [X^2*Y^2,Y^2*Z^2,Z^2*X^2]; divF = diff(F(1),X)+diff(F(2),Y)+diff(F(...

4 years ago | 0

Answered
How to get the derivate using bvp4c
I assumed Alpha = A in your code. clc; p=0.01; Betaf= 207; Betas = 17; Beta = 0.5; kof = 0.613; kos = 400; m = 1; b2 = ...

4 years ago | 0

| accepted

Answered
How can I more fully vectorize to eliminate for loops?
Wans2 = (sum(G.*(W.'-V),2)).'

4 years ago | 0

| accepted

Answered
Trying to use fsolve works over lower part of range (values < 10) but fails in upper part of range (values > 10)
It's very important that you have a good initial guess for pHv given Vbv. So looping over the complete range of Vbv and taking ...

4 years ago | 1

| accepted

Answered
List of all Binomial permutations with a certain number of events
n = 8; A = dec2bin(0:2^n-1)-'0' A4 = A(sum(A,2) == 4,:) 8*7*6*5/(4*3*2*1) % more general Ai = arrayfun(@(i)A(sum(A,2) == i,...

4 years ago | 0

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

4 years ago | 0

| accepted

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

4 years ago | 0

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

4 years ago | 0

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

4 years ago | 0

| accepted

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

4 years ago | 1

| accepted

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

4 years ago | 0

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)

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

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

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

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

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

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

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

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

4 years ago | 0

| accepted

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

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

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

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

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

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

4 years ago | 0

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

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

4 years ago | 0

Load more