Answered

How to write a summation code when the k is not equal to j

If all arrays involved have K elements, you can use h = ...; lambda = ...; f = ...; S = sum(h); H = S-h ; result = sum(...

How to write a summation code when the k is not equal to j

If all arrays involved have K elements, you can use h = ...; lambda = ...; f = ...; S = sum(h); H = S-h ; result = sum(...

14 hours ago | 0

Answered

How can I copy a column I already have and add it on to the end of my matrix?

A = [A A(:,4)];

How can I copy a column I already have and add it on to the end of my matrix?

A = [A A(:,4)];

17 hours ago | 0

Answered

why tis matrix is sparse?

Calculate number_of_nonzeros/(number_of_rows*number_of_columns) and you'll see that the matrix is sparse.

why tis matrix is sparse?

Calculate number_of_nonzeros/(number_of_rows*number_of_columns) and you'll see that the matrix is sparse.

19 hours ago | 0

Answered

Index exceeds matrix dimensions.

y0=y(end,:); instead of y0=y(end,1);

Index exceeds matrix dimensions.

y0=y(end,:); instead of y0=y(end,1);

19 hours ago | 0

| accepted

Answered

Why am I getting the following errors

dS = @(t, x) (dSV(t,x) - x(2)*dV(t,x))/x(5); dP = @(t, x) (dPV(t,x) - x(3)*dV(t,x))/x(5); dG = @(t, x) (dGV(t,x) - x(4)*dV(t,x...

Why am I getting the following errors

dS = @(t, x) (dSV(t,x) - x(2)*dV(t,x))/x(5); dP = @(t, x) (dPV(t,x) - x(3)*dV(t,x))/x(5); dG = @(t, x) (dGV(t,x) - x(4)*dV(t,x...

19 hours ago | 0

| accepted

Answered

How to solve an ODE with external time-varying source?

a) Save [t1 t2 ... tn], [x1 x2 ... xn] in two arrays T and X. b) Pass T and X to the integrator: [tsim,ysim] = ode45(@(t,y)fu...

How to solve an ODE with external time-varying source?

a) Save [t1 t2 ... tn], [x1 x2 ... xn] in two arrays T and X. b) Pass T and X to the integrator: [tsim,ysim] = ode45(@(t,y)fu...

22 hours ago | 0

Answered

How to find 3 unknows with Least square a*cosh(b*x)+c, not using toolbox?

data = load('koordinater'); x = data.x; y = data.y; fun = @(p)sum((p(1)*cosh(p(2)*x)+p(3)-y).^2); p0 = [1;1;1]; p = fminsea...

How to find 3 unknows with Least square a*cosh(b*x)+c, not using toolbox?

data = load('koordinater'); x = data.x; y = data.y; fun = @(p)sum((p(1)*cosh(p(2)*x)+p(3)-y).^2); p0 = [1;1;1]; p = fminsea...

3 days ago | 0

Answered

How to find the optimum intercept by fixing the gradient as a fit to experimental data?

Use polyfit to fit a polynomial of degree 0 against log(y) - n*log(x) and take exp() of the result. This gives you optimal A f...

How to find the optimum intercept by fixing the gradient as a fit to experimental data?

Use polyfit to fit a polynomial of degree 0 against log(y) - n*log(x) and take exp() of the result. This gives you optimal A f...

3 days ago | 2

| accepted

Answered

can someone write me a code for this?

Use MATLAB's "pdepe". Note that your equation can be written as du/dt = 1/r * d/dr (r * a^2 * du/dr)

can someone write me a code for this?

Use MATLAB's "pdepe". Note that your equation can be written as du/dt = 1/r * d/dr (r * a^2 * du/dr)

3 days ago | 0

Answered

solve pde with neumann boundary conditions

At the right boundary (x=x_n) D^2y/dx^2 ~ (dy_n/dx - dy_(n-1/2)/dx) /(x_n-x_(n-1/2)) ~ (dy_n/dx - (y_n-y_(n-1))/(x_n-x_(n...

solve pde with neumann boundary conditions

At the right boundary (x=x_n) D^2y/dx^2 ~ (dy_n/dx - dy_(n-1/2)/dx) /(x_n-x_(n-1/2)) ~ (dy_n/dx - (y_n-y_(n-1))/(x_n-x_(n...

3 days ago | 0

Answered

Dear Reserach Team! I need to calculate numerically definite integral of a function g(y), where g(y) is a numerical integral of f(x,y). Please advise how to do it (the details are shown below). Many thanks in advance!.

function main g = @(y) integral(@(x)f(x,y),0,1); s = integral(g,0,2,'ArrayValued',true) end function fun_f = f(x,y) ...

Dear Reserach Team! I need to calculate numerically definite integral of a function g(y), where g(y) is a numerical integral of f(x,y). Please advise how to do it (the details are shown below). Many thanks in advance!.

function main g = @(y) integral(@(x)f(x,y),0,1); s = integral(g,0,2,'ArrayValued',true) end function fun_f = f(x,y) ...

4 days ago | 0

| accepted

Answered

How to use fminsearch with a function containing vectors of symbols

Write a function for f: function main h1 = ...: h2 = ...; x0 = [x10,x20,y10,y20]; % initial guess for solution x = ...

How to use fminsearch with a function containing vectors of symbols

Write a function for f: function main h1 = ...: h2 = ...; x0 = [x10,x20,y10,y20]; % initial guess for solution x = ...

4 days ago | 0

| accepted

Answered

Forward Euler solution plotting

function main x0 = 0.0; x1 = 1.5; fun = @(x,y) y-x; h = [0.25 0.05 0.01]; for i = 1:numel(h) [x{i},y{i}] = e...

Forward Euler solution plotting

function main x0 = 0.0; x1 = 1.5; fun = @(x,y) y-x; h = [0.25 0.05 0.01]; for i = 1:numel(h) [x{i},y{i}] = e...

4 days ago | 0

Answered

Error using lsqcurvefit (line 262) Function value and YDATA sizes are not equal.

In "kinetics", use tspan = t; instead of tspan = [0 30720];

Error using lsqcurvefit (line 262) Function value and YDATA sizes are not equal.

In "kinetics", use tspan = t; instead of tspan = [0 30720];

4 days ago | 0

| accepted

Answered

How can I determine which roots are closest to the unit circle?

[~,ix] = min(abs(real(root_out).^2+imag(real_out).^2-1)./sqrt(real(root_out).^2+imag(real_out).^2)); root_out(ix)

How can I determine which roots are closest to the unit circle?

[~,ix] = min(abs(real(root_out).^2+imag(real_out).^2-1)./sqrt(real(root_out).^2+imag(real_out).^2)); root_out(ix)

7 days ago | 0

Answered

FZERO cannot continue because user-supplied function_handle, A and B must be floating-point scalars.

Make a loop over the elements of p. "fzero" cannot determine zeros of vector-valued functions (like in fzero(@(y) 2.*u.*y.*(20...

FZERO cannot continue because user-supplied function_handle, A and B must be floating-point scalars.

Make a loop over the elements of p. "fzero" cannot determine zeros of vector-valued functions (like in fzero(@(y) 2.*u.*y.*(20...

8 days ago | 0

| accepted

Answered

plots giving wrong out output

In your code, replace g1/2*m1 g2/2*m2 by g1/(2*m1) g2/(2*m2)

plots giving wrong out output

In your code, replace g1/2*m1 g2/2*m2 by g1/(2*m1) g2/(2*m2)

9 days ago | 1

| accepted

Answered

Question about using ODE45 to solve a differential equation using column vectors as inputs

Use "interp1" to interpolate to the time t for which the solver requires the scalar values of ho, Ta and I. Here is an example:...

Question about using ODE45 to solve a differential equation using column vectors as inputs

Use "interp1" to interpolate to the time t for which the solver requires the scalar values of ho, Ta and I. Here is an example:...

10 days ago | 0

| accepted

Answered

minimization fmincon with ode

To get dobjectfun/dx numerically, you had to solve even more ODEs: https://de.mathworks.com/help/optim/ug/optimizing-a-simulati...

minimization fmincon with ode

To get dobjectfun/dx numerically, you had to solve even more ODEs: https://de.mathworks.com/help/optim/ug/optimizing-a-simulati...

10 days ago | 0

| accepted

Answered

Optimizing parameters for a system of linear equations

One possible choice: a_i = g_i / 2 * sum_{j=1}^{j=65} (f_j - g_j) / sum_{j=1}^{j=65} (f_j * g_j) b_i = -f_i / 2 * sum_{j=1}^{j...

Optimizing parameters for a system of linear equations

One possible choice: a_i = g_i / 2 * sum_{j=1}^{j=65} (f_j - g_j) / sum_{j=1}^{j=65} (f_j * g_j) b_i = -f_i / 2 * sum_{j=1}^{j...

10 days ago | 0

Answered

Using a function with multiple variable

function main %Manual inputs a_Ge = 9.64; a_ZnS = 26.4; %Reading files water_files = csvread('Water_IOR_Hale.csv');...

Using a function with multiple variable

function main %Manual inputs a_Ge = 9.64; a_ZnS = 26.4; %Reading files water_files = csvread('Water_IOR_Hale.csv');...

11 days ago | 1

| accepted

Answered

Using Solve with 'albersheim'

Pfa = 7e-10; SNR = 14; Pd0 = 1.0; Pd = fzero(@(x)albersheim(x,Pfa)-SNR,Pd0);

Using Solve with 'albersheim'

Pfa = 7e-10; SNR = 14; Pd0 = 1.0; Pd = fzero(@(x)albersheim(x,Pfa)-SNR,Pd0);

11 days ago | 0

| accepted

Answered

solving many linear differential equations through ODE solver.

Don't use symbolic variables together with "many" differential equations. Use a numerical ODE integrator instead (e.g. ODE15S)....

solving many linear differential equations through ODE solver.

Don't use symbolic variables together with "many" differential equations. Use a numerical ODE integrator instead (e.g. ODE15S)....

11 days ago | 1

| accepted

Answered

how do i solve for 't' ?

Try eqn1 = 190.0 == 380.0-379.69109947074029287421462846085/2*(exp((-1000842.1052631578947368421052632+1000813.5574673472470455...

how do i solve for 't' ?

Try eqn1 = 190.0 == 380.0-379.69109947074029287421462846085/2*(exp((-1000842.1052631578947368421052632+1000813.5574673472470455...

11 days ago | 0

Answered

How can I make an array of sin(1), sin(2), ... , sin(100)?

x=1:100; sinarray=sind(x)

How can I make an array of sin(1), sin(2), ... , sin(100)?

x=1:100; sinarray=sind(x)

11 days ago | 0

| accepted

Answered

The polynomial for the cubic spline is with x or (x-xi) ?

Read the chapter "pp - piecewise polynomial" under "Output Arguments" in https://de.mathworks.com/help/matlab/ref/spline.html

The polynomial for the cubic spline is with x or (x-xi) ?

Read the chapter "pp - piecewise polynomial" under "Output Arguments" in https://de.mathworks.com/help/matlab/ref/spline.html

14 days ago | 0

| accepted

Answered

Cubic spline in Matlab works with natural boundary?

By default, MATLAB uses "not-a-knot" condition in end points: http://www.cs.tau.ac.il/~turkel/notes/numeng/spline_note.pdf

Cubic spline in Matlab works with natural boundary?

By default, MATLAB uses "not-a-knot" condition in end points: http://www.cs.tau.ac.il/~turkel/notes/numeng/spline_note.pdf

14 days ago | 1

| accepted

Answered

solving unknown variables in matrices

[4 -2 1; 1 1 1;4 2 1]*[k;l;m] = [4; 1; -4]

solving unknown variables in matrices

[4 -2 1; 1 1 1;4 2 1]*[k;l;m] = [4; 1; -4]

14 days ago | 1

Answered

I get this error:"This system does not seem to be linear."

The product of differentials in your equations (diff(theta1)*diff(theta3), e.g.) makes it impossible to use ODE45. I don't kno...

I get this error:"This system does not seem to be linear."

The product of differentials in your equations (diff(theta1)*diff(theta3), e.g.) makes it impossible to use ODE45. I don't kno...

14 days ago | 2

| accepted