Community Profile

photo

Alan Stevens


Last seen: Today
519 total contributions since 2020

Alan Stevens's Badges

  • 6 Month Streak
  • Knowledgeable Level 4
  • Pro
  • First Answer

View details...

Contributions in
View by

Answered
How would I plot a piecewise summation.
Something like this? tau = 1; t = 0:0.1:10; n = ceil(t/tau); for i = 1:numel(n) S = 0; for k = 1:n(i) ...

ungefär 2 timmar ago | 0

Answered
oblique throw for golf ball
A little more like this perhaps: v0 = [15:60]; %initial speed a = [15:60]; %angle g = 9.81; %gravitational acceleration ...

ungefär 2 timmar ago | 0

Answered
Using Linear congruential to generate 10,000 uniform random variables
You need an intial value for X(1); and you need to set for n=2:10000 X(n+1)=mod((a*X(n)+c), m); end

ungefär 21 timmar ago | 0

| accepted

Answered
Not able to stop value of iterations
Better as something like tol = 10^-8; % or whatever you desire maxiter = 100; % ditto err = 1; its = 0; while ...

ungefär 22 timmar ago | 0

Answered
How can I store values in empty matrix to plot later?
You need to wotk with normalized population numbers. You can renormalize at the end. %Epidemic Simulation %Author: James Metz...

2 dagar ago | 0

Answered
Fitting multiple datasets to non-linear coupled ODE's - fminsearch
Why not just use errT=norm(cellHND - chND)+norm(cellLND - clND); instead of looping through the sums.

2 dagar ago | 0

Answered
why is there an error in line 13 of my coding ?
In addition to Walter's correction, note that f and d contain a different number of elements, so element by element operations w...

2 dagar ago | 0

Answered
why do I have an error on the length function?
You have misspelled length.

2 dagar ago | 1

Answered
How to plot ode
First, you should combine your three "prom" ode functions into one IC = [n0 m0 h0]; [t, NMH] = ode45(@(t,nmh) prom(t,nmh,V1), ...

3 dagar ago | 0

| accepted

Answered
Grouping In Pairs the Coefficients of an Array and Computing the Average of each group
Use reshape to get the pairs in two rows. AG = reshape(A,2,4); Then the average of each group is simply Agav = mean(AG);

3 dagar ago | 0

| accepted

Answered
I'm trying to solve this problem in MatLab
In terms of real numbers the integral is only defined for -1<=x<=1. By making the substitution x^2 = sin(theta) where -pi/2<=t...

3 dagar ago | 0

Answered
Plot 4 diagrams in one plot
Like this? mu=[0 0.1 1 10]; tspan=[0 20*pi]; x0=0.5;dx0=0; IC=[x0 dx0]; % initial conditions for i=1:4 dxdt=@(t,x)[x(2); ...

4 dagar ago | 0

Answered
Raising a negative value to a fraction power?
Exponentiation has a higher priority than negation, so -2^1.2 is -(2^1.2), this results in a negative real. On the other had (-...

4 dagar ago | 1

| accepted

Answered
Matrix Question for 12*12 matrix
Supposing M is the 12x12 matrix, then M([1,2,4],:)=[]; M(:,[1,2,4])=[]; should remove the appropriate rows and columns.

4 dagar ago | 0

| accepted

Answered
Cant get my loop to work
Replace your k loop by for k=1:size(IC,1) [V, CT] = ode45(@fn, Vspan, IC(k,:)); figure; plot(V,CT(:,1),V,CT(:,2),V,CT(:,3...

4 dagar ago | 0

| accepted

Answered
Error - Inputs must be floats 'ode45'
Like so (Note: no need for syms): a = 0.2; c = 1; b = (2*c/(1-a)); inital(1)=1; inital(2)=1; l = @(t,s) [s(1)*(1-s(1))*(a+...

4 dagar ago | 1

| accepted

Answered
Need help on solving this bisection method question
You really don't need any symbolic parameters here; and you had the logic with a and b the wrong way round! Try f = @(x) -2*x....

5 dagar ago | 1

| accepted

Answered
*Matrix dimensions must agree error*
Look up .* (i.e. dot*), ./ and .^ for element by element actions. Replace the later part of your code by x=linspace(0.5,1);...

5 dagar ago | 1

| accepted

Answered
Incorrect Intersection Output of Two Lines
After your two for loops put the following intersectfn = @(t) interp1(tklaus,xk,t) - interp1(thans,xh,t); t0 = 50; % Initial ...

5 dagar ago | 0

Answered
How to solve a equation iteratively?
Look at the fzero function. Assuming you know P as a function of K, then with an initial guess for K K0 = ...' % initial gue...

5 dagar ago | 0

| accepted

Answered
for loop for variables
You probably want o = 90; not 0 = 90; Also, Matlab indexing starts at 1 not zero, so, perhaps, t = 1:101, then xd(t) = sin(wd*...

5 dagar ago | 0

Answered
Fitting gaussian exponential to logscale
The logs of the y values are negative, whereas your function will return positive values only! You are probably better off tryin...

5 dagar ago | 1

| accepted

Answered
Trying to code from Polymath
Here's a basic MATLAB version. % Initial conditions Ca0 = 2; Cb0 = 4; Cc0 = 0; Cd0 = 0; T0 = 800; IC = [Ca0 Cb0 Cc0 Cd0...

5 dagar ago | 0

| accepted

Answered
How do you solve the non-growth rate of yeast using non-linear regression analysis?
You can do it as follows. Notice that there are, in effect, only four paramters to fit: x = 0:0.5:5; % mg/L k = [0, 0.22390...

5 dagar ago | 1

Answered
can ı plot this chart with a given equation?
Here's a starter. You can add the other equations and labelling V = @(S) 0.349109 + 6.00940*S + 0.047467*S.^2; S = logspace(-...

6 dagar ago | 1

| accepted

Answered
create tuples of values in array
How about x=[x1,x2,x3,..,xn]; y=[y1,y2,y3,..,yn]; xy = [x; y]; X = xy(1,:); Y = xy(2,:);

6 dagar ago | 0

Answered
Problems with the legend function.
You might have to change the plot order a little. More like this perhaps: M=1000; x=linspace(-11,15,M); y=linspace(-7,11,M);...

6 dagar ago | 0

Answered
How can I solve the determinant of large-sized symbolic matrix: det(A)=0?
Set the diagonals of D to be just, u, say. With vpasolve you get 20 numerical values of u almost as quickly as 5. You can then...

6 dagar ago | 0

Answered
My IF function for a set of data is not working.
You could replace if Da<48 X=32-25*log10(LUA-Y) else X=Grx end by the fol...

6 dagar ago | 0

Answered
How do i replace Euler's method with ode45?
Here's one way. I've simplified the data input - you can add the bells and whistes! % A script to animate the motion of the sim...

7 dagar ago | 0

Load more