Answered

How can I define the variable handles for this code. A is a numerical value not text "Undefined variable handles or class "handles.A"

Do you want something like this? xo = 0.1; vo = 3; m = 1; c =10; k = 100; wn = sqrt(k/m); c_c = 2*m*wn; zeta = c/c_c; t = li...

How can I define the variable handles for this code. A is a numerical value not text "Undefined variable handles or class "handles.A"

Do you want something like this? xo = 0.1; vo = 3; m = 1; c =10; k = 100; wn = sqrt(k/m); c_c = 2*m*wn; zeta = c/c_c; t = li...

17 hours ago | 0

Answered

how to solve a system of equations in matlab

Try this f = @(x) (x+2).*(x<=0) + (-x+2).*(x>0); (x<=0) returns 1's where it's true and 0 where it's false. Similarly for (x>...

how to solve a system of equations in matlab

Try this f = @(x) (x+2).*(x<=0) + (-x+2).*(x>0); (x<=0) returns 1's where it's true and 0 where it's false. Similarly for (x>...

2 days ago | 0

| accepted

Answered

Trying to plot Fourier series, but just getting a straight line??

When I run this A0=1; T=1; n=6; t = 0 : T/256 : T; nn = length(t); f = zeros(n,nn); s = zeros(nn); for ii = 1:n for j...

Trying to plot Fourier series, but just getting a straight line??

When I run this A0=1; T=1; n=6; t = 0 : T/256 : T; nn = length(t); f = zeros(n,nn); s = zeros(nn); for ii = 1:n for j...

2 days ago | 0

Answered

Wha'ts wrong with this?

Try f = @(x) sin(x+1)*sqrt(x+1); p = polyfit([1,2,3,4],[f(1),f(2),f(3),f(4)],3); x = 1:0.01:4; y = polyval(p,x); plot([1,2,...

Wha'ts wrong with this?

Try f = @(x) sin(x+1)*sqrt(x+1); p = polyfit([1,2,3,4],[f(1),f(2),f(3),f(4)],3); x = 1:0.01:4; y = polyval(p,x); plot([1,2,...

3 days ago | 2

| accepted

Answered

Trying to plot Fourier series, but just getting a straight line??

Replace f(ii) = f(ii,j) + (4*A0/(2*ii-1)*pi) * sin(2*pi*(ii-1)*t(j)); with f(ii,j) = f(ii,j) + 4*A0/((2*ii-1)*pi) *...

Trying to plot Fourier series, but just getting a straight line??

Replace f(ii) = f(ii,j) + (4*A0/(2*ii-1)*pi) * sin(2*pi*(ii-1)*t(j)); with f(ii,j) = f(ii,j) + 4*A0/((2*ii-1)*pi) *...

3 days ago | 0

| accepted

Answered

Heaviside function is not integrated

You could do it this way, without the symbolic stuff: %% Castigliano E=210e9; %e-modulus aluminium=69 steel-210 rho=8...

Heaviside function is not integrated

You could do it this way, without the symbolic stuff: %% Castigliano E=210e9; %e-modulus aluminium=69 steel-210 rho=8...

3 days ago | 1

| accepted

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

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

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

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

3 days ago | 1

| accepted

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

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

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

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

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

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

5 days ago | 0

| accepted

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.

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.

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

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

5 days ago | 0

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

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

6 days 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);

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);

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

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

6 days 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); ...

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

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

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

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

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.

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

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

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

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

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

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

8 days 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);...

*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);...

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

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

8 days ago | 1

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

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

8 days 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*...

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

8 days ago | 0

| accepted

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

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

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

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

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

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

8 days ago | 1