Community Profile

Alan Stevens

Last seen: Today Active since 2020

Content Feed

View by

Increasing number of data points by linear interpolation method
Try doc interp1

3 giorni ago | 0

I have two 4x4 matrices. I sub-divided these matrices in 4 2x2 matrices each. Now I want to compare these 2x2 matrices.
Something like this: M1 = [8 7 6 9; 11 13 4 21; 2 69 33 27; 5 3 1 8]; M2 = [0 1 0 1; 1 0 1 0; 0 1 0 1; 1 0 1 0]; M = M1.*M2...

3 giorni ago | 0

| accepted

Solving inter-connected ODE equations
The answer is Yes. You have a system of 9 ODE's. Try help ode45 for details on how to do it.

6 giorni ago | 0

support vector regression - Coefficient of Determination
Have a look at: https://uk.mathworks.com/matlabcentral/fileexchange/34492-r-square-the-coefficient-of-determination?s_tid=srcht...

7 giorni ago | 0

Value of infinite integral is different
The value of your integral is infinite! Are you sure you have written the function S correctly?

7 giorni ago | 0

Evaluating the following integral using comp trap method for 2 trapezoids
You need to divide by the true value of the integral in calculating the error: y = @(x) (10 - 2*cos(x)); b= pi/3; a = 0; ...

8 giorni ago | 0

How to Use Nested For Loops to Create a Coupled System of Equations
More like this perhaps (you've very tight tolerances!): options = odeset('RelTol',3e-14,'AbsTol',1e-15,'Stats','on'); [t,y]=od...

11 giorni ago | 0

| accepted

Solving Trigonometric Equations with More Than One Variables
You have theta = 30degrees, so sin(theta) is 1/2. Therefore, in equation 2, you have cos(psi)/2 = 0.76, so cos(psi) > 1. If ...

11 giorni ago | 0

Plot 2D surf from 3 columns (X, Y, Data)
plot3 will plot your points as a line (or series of points). To get a surface, set up regular coordinates over the appropriat...

17 giorni ago | 1

I want to plot v/vth as a function of y(where y varies from [0 d] and d=6)
The integral is infinite if you let phi go all the way to phim. If you restrict the upper limit of the integral to be less than...

29 giorni ago | 1

| accepted

4th order runge-kutta method to solve two 1st order differential equations
Like this? %%4th order runge-kutta for Project 2 fy=@(t,y,z) z; fz=@(t,y,z) (36000/(1500-40*t))-9.81-((0.1962*z^2)/(1500-40*t...

circa un mese ago | 0

| accepted

How to convert this equation to code?
Use ^ not **

circa un mese ago | 1

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

circa un mese ago | 1

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

circa 2 mesi 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(...

circa 2 mesi 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...

circa 2 mesi 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...

2 mesi 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...

2 mesi 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)

3 mesi 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 =...

3 mesi ago | 0

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

3 mesi ago | 0

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

3 mesi 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-...

3 mesi 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...

3 mesi 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...

3 mesi 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...

3 mesi 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...

4 mesi 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))*(...

4 mesi ago | 1

| accepted