# Alan Stevens

**Statistics**

**MATLAB Answers**

**0** Questions

**1,026** Answers

RANK**53**

of 250,391

REPUTATION**2,736**

CONTRIBUTIONS

**0** Questions

**1,026** Answers

ANSWER ACCEPTANCE **
0.00%
**

VOTES RECEIVED**266**

RANK

of 17,396

REPUTATION**N/A**

AVERAGE RATING**0.00**

CONTRIBUTIONS**0** Files

DOWNLOADS **0**

ALL TIME DOWNLOADS**0**

RANK

of 104,077

CONTRIBUTIONS

**0** Problems

**0** Solutions

SCORE**0**

NUMBER OF BADGES**0**

CONTRIBUTIONS**0 Posts**

CONTRIBUTIONS**0** Public Channels

AVERAGE RATING

CONTRIBUTIONS**0** Highlights

AVERAGE NO. OF LIKES

**Content Feed**

How would you I write a matlab function for theta that represents the 2nd order differential of the torque equation?

Does this help? % Theta seems to have two components, so: D(theta) = [p1+p2+2*p3*cos(theta(2)) p2+p3*cos(theta(2)); ...

19 hours ago | 1

| accepted

Error message with arrays

You only need h = [2:20:220]; t_a = 293; q_flux = 800; n = length(h); y = q_flux./h+t_a; i = i+1; plot(h,y)...

1 day ago | 0

How to solve two coupled differential equations using ode45.

"Why is my previous code is not working properly by treating the problem to be a DAE." I don't know! "Also I noticed you wrote...

8 days ago | 1

Multiple Anonym Function return wrong values

Here's one solution: C = [4622 5480 18923]*1e-12; U = [454e3 454e3-20e3 20e3].*sqrt(2); W = Energy(C,U); disp(W) function W...

8 days ago | 0

| accepted

Hi, is it possible to have variables in an ode45 that varies according to another function?

Put something like [T, p, rho, speedsound] = atmos(height); immediately after height = x(1); in function dynameqn. Not sur...

16 days ago | 0

root finding and plot of graph

Are you looking for something like this? hi = 1e-6; lo = 1e-9; n = 500; dt = (hi-lo)/n; t3 = lo:dt:hi; y = f(t3); subplo...

16 days ago | 0

Calculator result and MATLAB result are different

Have you checked that both are using degrees, or both radians? The Matlab as you've written it is using radians (use sind(24) a...

19 days ago | 1

How can I rotate a set of points by an angle around its origin?

Do you mean like this? ITM = [461400.0758 617474.3059 461400.8069 617475.4609 461400.8069 617475.4609 461402.3069 617477.633...

21 days ago | 1

| accepted

Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.

Try replacing x(4) = Velocities(3608.9,5249.3); by x(4,:) = Velocities(3608.9,5249.3); Same for x(5).

24 days ago | 0

Removing zeros from matrix

Like this? A = [1 2 3 4 5 6; 1 2 3 4 5 6; 1 2 3 4 5 0; 1 2 3 4 0 0; 1 2 3 0 0 0]; B = A'; B=B(:); B(B==0)=[]

2 months ago | 0

Error in ODE arguments

I suspect you mean like this (notice the way M divides, using the back-slash): % Numerical solution of IVP % M*xddot + C*x...

2 months ago | 2

| accepted

How to Approximate The Solution for an Initial Value Problem?

Try f = @(t,x) [x(2); sin(1.9*t)-4*x(1)]; [t,x] = ode45(f,[0,150],[1,0]); plot(t,x)

2 months ago | 1

| accepted

Creating a set range for a function

(x < 3) && (x > 25) An individual element of x can't be both less than 3 and greater than 25 at the same time. If here are ma...

2 months ago | 0

| accepted

Plotting the tangent line for newton raphson method

Like this? fx = @(x) x.^2 -2; dfdx = @(x) 2*x; n_step = 7 ; % Anzahl der durchzuführenden Schritte für Newtonverfahren...

2 months ago | 0

| accepted

Fit scatter plot with a curve

More like ths? x = [0.2337;0.296;0.3071;0.4208;0.2055;0.9597;0.8683;0.243;0.3363;0.2793;0.5292;0.2471;0.2282;0.4774;1.0392;0.43...

2 months ago | 1

| accepted

Generating random numbers with a different probabilities

Assuming there are just two levels of probability, and that the numbers are real, not just integers, you could try: p50 = 0.75;...

2 months ago | 1

Hi, what does ; exactly mean?

It means start a new row, e.g. x = [1 2; 3 4]; disp(x)

2 months ago | 0

Solve the IVP y′′′=sin(y2)+y′+cos(t), provided with an appropriate set of initial conditions of your choice, and using Matlab's ODE45 function.

Like this? (Note the IC for d^2y/dt^2 must be consistent with the values chosen for y(0) and dy(0)/dt). Change the IC's and tim...

2 months ago | 0

Need Help Solving System of ODEs

You haven't included the first term on the right-hand side of your equation for dV/dt, nor for dgamma/dt.

2 months ago | 1

spring mass using ode45

Like this x0 = [0; 0]; tspan = [0, 10]; [t, x] = ode45(@func, tspan, x0); subplot(2,1,1) plot(t, x(:, 1)); grid('on...

2 months ago | 0

I am getting error in this program. Please suggest the corrections.

Change c = [1 2 2 3 4 5 6 7]; to c = [1 2 3 4 5 6 7];

2 months ago | 1

Hello, I'm trying to plot one non-piecewise function and two piecewise functions in one graph but I keep getting an error. I don't understand the two error messages below.

You need to put the non-local functions at the end, as in the following. There were several other errors. I don't know if my co...

2 months ago | 0

How to Solve equation using Eulers method in Matlab?

Here's part (a) for you - definitely not a straight line!

2 months ago | 0

| accepted

I need to set up a Runge Kutta solver for water leaving a bucket through a certain diameter nozzle as function of time, it says array indices must be positive integers/log val

Indices in Matlab start at 1, not 0, so you need for i=1:60:200 not for i=0:60:200

3 months ago | 0

How to get one output for each input into an equation in MATLAB?

mu = mu_max * (x./(x+Ks)); % Notice it is ./ not just /

3 months ago | 0

How to solve 'Index number exceeds number of array elements(1)'

You don't update XSOL, so when ct is 2, XSOL(ct) doesn't exist.

3 months ago | 0

| accepted

A question about FitzHugh-Nagumo model

Like this? tspan = [0 100]; v0 = 0; w0 = 0; IC = [v0 w0]; A=0.5; B=0.05; Epsilon=0.005; I=@(t)sin(t); %%%%%%%%%%%%%%...

3 months ago | 0

| accepted

How to find parameters that minimize a difference

Use fminsearch and use the norm of the differences. help fminsearch

3 months ago | 2

I want to combine 2 variables in matlab into one variable

If they are imported as, say, c1 and c2, then you can simply write c = [c1; c2]; then delete the c1 and c2 if you don't need t...

3 months ago | 0

| accepted

How can i call an equation and it's derivative inside a matlab function?

Like this, perhaps: % TC is given in terms of percentage! x0=0; TC=10^-4; error=TC+1; i=0; x(1)=x0; while(error>TC) [f...

3 months ago | 0