Community Profile # Alan Stevens

Last seen: Today Active since 2020

#### Statistics

• • • • #### Content Feed

View by

need help with mass transfer modelling
Here's one way of doing it: % You need to do the time integration for each C separately C = 150:50:250; % Choose your own ...

alrededor de 3 horas ago | 0

Function of a variable
You need to define sc before using it in B. In B you have ...1000/dref*dref.... This just means the dref va;lues cancel each ...

9 días ago | 0

I have plotted two circles and I want to anything outside of the first circle (unit circle) to not be plotted or excluded.
Here's one way: np = 100000; min = -pi*1000; max = pi*1000; hold on; a = 0; b = 0; z = a + (1j*b); e = linspace(...

12 días ago | 0

| accepted

How to implementation PSO in Matlab?
Have a look at https://uk.mathworks.com/matlabcentral/fileexchange/67804-particle-swarm-optimization-pso-matlab-code-explanation...

14 días ago | 0

| accepted

Getting regression weights from histogram
Something like this perhaps? % Dummy data N = 1000; M = N/40; T = randn(N,1); h = histogram(T,M); W = max(h.Values)-h.Valu...

28 días ago | 0

| accepted

Custom fitting using equation from differential function
You equation has the analytical solution y = (A/B)*(1-exp(-B*t)). Use fminsearch to fit the parameters, or the curve fitting to...

alrededor de 1 mes ago | 0

Using the nodal method in ventilation analysis
Try removing J_inv=inv(J); and replacing (J_inv(i,j)*fP(i)) by J(i,j)\fP(i)

alrededor de 1 mes ago | 0

| accepted

Using Euler's method to solve the system of ODEs
Probably easier to keep tabs on what is happening if you simplify as follows: r=2.5; p=2; c=0.1; b=0.1; q=1; k=0.1; h =...

alrededor de 1 mes ago | 0

Error with the SIR Model
Update N at each timestep. Plot I and R on a different scale from S.

alrededor de 1 mes ago | 0

ODE45 returns NaN
t = 0 causes a problem. Try tspan = [0.1 100]; for example.

alrededor de 1 mes ago | 0

How can I do an elliptic curve in Matlab?
Here's one simple way: % y^2 - y = x^3 - x % y = (1 +/- sqrt(4x^3 - 4x + 1))/2 n = 1000; x = -2:1/n:2; d = sqrt(4*x.^3-...

alrededor de 1 mes ago | 0

Phase Portrait of ODE system
Do you mean something like this: % Part IIa. Base Case % Phase Portrait % % r=2.5; p=2; c=0.1; b=0.1; % % [x,v]=meshgr...

alrededor de 2 meses ago | 0

Plot with while loop
By the time you get to the plot command you only have a single value of t1 and a single value of y1 as you overwrite each of the...

2 meses ago | 0

| accepted

How should I approach solving differential equation as function of two variables r, k?
You need to call the ode with something like [t, y] = ode45(@(t,y) deq(t,y,r,k),tVec,y0,r,k); where you pass values of r and k...

2 meses ago | 1

I need help plotting
More like this perhaps: Z1=500; Z2=50; Z3=500; u=1; tau1=(2*Z2)/(Z1+Z2); tau2=(2*Z1)/(Z1+Z2); tau3=(2*Z3)/(Z3+Z2); p1=(Z...

2 meses ago | 1

1D Heat Equation Explicit Scheme
Look at for i=1:(N) if (alpha*DELTA_t)/(DELTA_x^2)<=0.5 T(i,j+1)=T(i,j)+((alpha*DELTA_t)/((DELTA_x)^2))*(...

2 meses ago | 1

| accepted

Solving a system of Second Order Equations
Not sure there is a symbolic solution, but it's easy enough to get a numerical one: tspan = [0 1]; % Start and end times % In...

2 meses ago | 1

How to solve 4th order Runge-Kutta for different initial conditions?
Here's a rather crude method (together with some corrections). You should be able to turn this into a much more elegant version...

3 meses ago | 1

| accepted

1D Heat Equation Explicit Scheme (fixed)
With for i=0:0.1:50 you are trying to index variables with zero. However, Matlab's indexing starts at 1.

3 meses ago | 1

How to plot Homogeneous solution and Particular integral seperately of a second order differntial equation using ode45
ode45 just solves first order equations, so turn your second order equation into two first order ones, like so: y' = v v' = -4...

3 meses ago | 0

Trying to plot R_K 4th order, but keep getting straight line?
Check these equations F_sir = @(s,i,r) -a*s*i; % change the function as you desire G_sir = @(...

3 meses ago | 1

| accepted

Not enough input arguments; fzero function
Replace T_mix = fzero(fun,T_mix_0); by T_mix = fzero(@fun,T_mix_0);

3 meses ago | 1

I am trying to use the trapezoidal rule to compute the flow rate of fluid through a pipe.
I think it needs to be more like this: % Velocity distribution function of the pipe % Area = pi*r^2 % dA = 2*pi*r dr % Q = V...

3 meses ago | 0

| accepted

How to get area under the fit attained by Curve Fitting tool?
Try help trapz

3 meses ago | 0

Progressively slower performance and task constraints using matrix and loops
With these particular functions it's easy to precalculate the Jacobian function and do everything numerically (and quickly). Fo...

3 meses ago | 0

Local Stiffness Matrix Negative
How about replacing if i==2 & j==2 k=A(e)*E/(L/5); elseif i==2 & j==1 k=...

3 meses ago | 0

Save array values in a for loop
Try replacing error = max(abs(double(y1-z1(vx)))) with error(i) = max(abs(double(y1-z1(vx))));

3 meses ago | 0

| accepted

Solving a PDE with two variables using cank nicolson method
Matlab indices start at 1, so the loops i, j and K in the following for i=0:N for j=0:M for K=0:1 f(x,y...

3 meses ago | 0