# Alan Stevens

**Statistics**

RANK**55**

of 243 869

REPUTATION**2 570**

CONTRIBUTIONS

**0** Questions

**972** Answers

ANSWER ACCEPTANCE **
0.00%
**

VOTES RECEIVED**241**

RANK

of 17 056

REPUTATION**N/A**

AVERAGE RATING**0.00**

CONTRIBUTIONS**0** Files

DOWNLOADS **0**

ALL TIME DOWNLOADS**0**

CONTRIBUTIONS**0 Posts**

CONTRIBUTIONS**0** Public Channels

AVERAGE RATING

CONTRIBUTIONS**0** Highlights

AVERAGE NO. OF LIKES

**Content Feed**

Tring to solve for a transcendental equation

You can rearrange the equation as eigen*tan(eigen) = Bi and use fzero as below. However, because of the nature of tan, your res...

ungefär 21 timmar ago | 0

| accepted

Question regarding MATLAB code to solve for electron in constant electric and magnetic field

If you are going to use global variables they need to be declared outside the function as well as inside. Your values of q and ...

4 dagar ago | 0

Hello, I am trying to plot the transmission coefficient vs energy for the double barrier potential, but I get an error. May I know what I have done wrong here?

See the following V_0 = 0.2800; % Barrier strength in eV hbar = 1.054571596e-34; % Reduced Planck constant m = 5.465629128e-3...

4 dagar ago | 0

Simulation of point kinetics reactor equations

There are seven equations if you are using all six delayed neutron groups. You don't give your reactivity, nor the individual b...

11 dagar ago | 0

| accepted

calculating angle between line of best fit and x axis

Take the arctangent of the gradient of the straight line.

11 dagar ago | 0

deleting separate zeros from vector

Here's one way (there is probably a slicker way!): A = [ 0 0 1 0 0 0 1 0 1 0 0 1 5 9 8 2 0 3 0 1 0 0 0 ]; ...

12 dagar ago | 0

Making a Euler Method script to solve for velocity but am encountering "Array indices must be positive integers or logical values" Error

Try changing your loop to for i=1:numel(t) %%% i loop not t f = (g - (D * p * A * v(i).^2)/(2*m)); %%% v(i) v(i+1) ...

12 dagar ago | 0

Error solving for a particular variable from two equations

You could use fzero: TonTc = 0.01:0.01:0.99; a = zeros(1,numel(TonTc)); a0 = 1; % initial giuess for k = 1:numel(a) ...

13 dagar ago | 0

| accepted

Replacing sym with function handle

Do you mean something like this? phi = pi/3; [nr, wr] = fn(phi); disp(phi) disp(nr(4)+56*3/2) disp(wr(4)) function [nr...

13 dagar ago | 0

I'm trying to solve this system of ODE's describing a mechanical spring model.

Might be better to forget about symbolics, treat each 2nd order ode as two first order ode's and do the following: %applied for...

16 dagar ago | 0

Solving a first order ODE with Euler backwards method

Your y_true is only valid for t>= 5 (smaller values give imaginary results for y). So, try going from 5 to 8: % y_true = log(t...

16 dagar ago | 0

| accepted

Need help to create a loop

How about: e=2.7183; gamma=0.1333; k = [1,9,23,7,23,9,20,29,63,102,73,59,27,130,75,185,70,92,326]; Rt=0:0.01:10; P = zero...

16 dagar ago | 1

Newton's method iterations

I suggest you plot a graph of your function, then you can see where good initial estimates would be. For example f = @(x) 2*ex...

17 dagar ago | 0

the variable appears to change size every loop iteration

Answered here: https://uk.mathworks.com/matlabcentral/answers/1464024-the-variable-appears-to-change-size-every-loop-iteration?s...

18 dagar ago | 1

Writing the dirac function as a function handle

Try dirac_i = @(x) x==i; % This assumes i has been fixed before the function is defined

18 dagar ago | 0

| accepted

How to plot 2 graphs with input as a range and join them together?

Like this p0=0; p1=6; p2=1; p3=3; p4=3; t=[0:0.01:1]; x1 = (1/6)*[((((-t).^3)+(3*(t.^2))-(3*t)+1)*p0)+(((3*(t.^3))-(6*(t....

18 dagar ago | 0

the variable appears to change size every loop iteration

You don't need the loop: If = [0 0.5 1.0 1.5 2.0 2.5]; Ea = [0 75 150 205 242 270]; Ra = 0.14; RI = 2; la = 100; Ifield = ...

18 dagar ago | 1

Unable to find solution to matrix using Gauss Seidal code. How should I proceed to get the solution?

You are dividing by A(i,i) some of which are zero. These will introduce NaNs.

19 dagar ago | 0

Solving Eqn with Varying Variable (Ms)

Like this: a1a4 = 1./[1, 2, 4, 10]; n = 10000; p4p1 = 1:n; M = zeros(numel(a1a4),n); for j = 1:numel(a1a4) m = 1.01; ...

21 dagar ago | 1

| accepted

To solve two 2nd order coupled differential equation using ODE45?

Replace each 2nd order ODE by two 1st order ODEs. e.g. set V1 = X1', V2 = X2', then V1' = (50*sin(f(t) - V1)*V2')/sin(f(t)), V...

22 dagar ago | 0

| accepted

Using Ode45 to solve dynamics problem (ISA model)

Like this z0 = 39045; %const.h0; v0 = 0; %const.v0; t0 = 0; tf = 800; N = 60000; tspan = linspace(t0, tf, N); X ...

22 dagar ago | 0

| accepted

Curve fitting a power law function

Like this? h0=0.654; %[m] This seems to be unused h_t=[0.654;0.628;0.604;0.582;0.56;0.54;0.52;0.501;0.482;0.465;0.447;0.43;0.4...

24 dagar ago | 0

Finding approximate real solution to a equation

You don't need syms here. Try the roots function. help roots

26 dagar ago | 0

| accepted

Two Step Adam Bashford Method

As follows f=@(t,y) 3*t+y/t; alpha=5; a=1; b=2; n=3; [t, w, h] = abs2(f, a, b, alpha, n); plot(t,w,'-o'),grid xlabel('t'...

27 dagar ago | 0

| accepted

How to add iterations in Newton Raphson code of Kepler Equation

Like this M = 0.908; e = 0.725; tol = 10^-6; [E, its] = Kepler(M,e,tol); disp(['E = ' num2str(E) ' after ' num2str(its), ...

27 dagar ago | 0

| accepted

Let x=[2 4 6 8 10] and y=[1 3 5 7 9]. Compute for the vector z whose elements are equal to z= (xy+ y/x)/[(x+y)]^((y-x)) + 10^(x⁄y)

You need z = (((x.*y)+(y./x))./((x+y).^(y-x)))+10.^(x./y) % another dot here ^

27 dagar ago | 0

| accepted

how to find the root of function?

Like this? n_h0 = 0.1; %initial guess n_h = fzero(@n_h_fun, n_h0); disp(n_h) function a=n_h_fun(n_h) alpha=0.74; ...

28 dagar ago | 1

| accepted

Newton's method for 2 dimension vectors

LIke this? % Functions f = @(XY) [XY(1).^3 - 3*XY(1).*XY(2).^2 - 1; 3*XY(1).^2.*XY(2) - XY(2).^3]; J = @(XY) [...

29 dagar ago | 0

How to plot a (which is changing from 0-1 in 0.01 increments) vs x(2) (using a for loop and fsolve to find the solution of a nonlinear equation containing x(s) sol based on a

Your first equation is a simple quadratic in x(1); your second is a quadratic in x(2) that depends on x(1), so, assuming you are...

ungefär en månad ago | 0