Answered

How to create a 10-by-10 matrix that is all zeros except for ones in the diagonal (runnig from top left to bottom right) using a for-loop?

You can just ue the command eye(10)

How to create a 10-by-10 matrix that is all zeros except for ones in the diagonal (runnig from top left to bottom right) using a for-loop?

You can just ue the command eye(10)

31 minutos ago | 0

Answered

How to control the outcome of an ODE?

How about just modifying dydt(5) within the function to % Temperature if y(5)>=600 dydt(5) = 0; else dydt(5) = ( (...

How to control the outcome of an ODE?

How about just modifying dydt(5) within the function to % Temperature if y(5)>=600 dydt(5) = 0; else dydt(5) = ( (...

alrededor de 19 horas ago | 0

| accepted

Answered

Error when solving differential equations

Your function has function dydt = vdpi1(t,y) but you really want dy returned, not dydt.

Error when solving differential equations

Your function has function dydt = vdpi1(t,y) but you really want dy returned, not dydt.

1 día ago | 0

Answered

not getting plot , why?

Arrange it like this sigma=0.047193; V_tip=180; W=180; Cd_avg=0.01; R=2.235; k=1.1; A=pi*R.^2; P_e= 61147.4; h=0:100:...

not getting plot , why?

Arrange it like this sigma=0.047193; V_tip=180; W=180; Cd_avg=0.01; R=2.235; k=1.1; A=pi*R.^2; P_e= 61147.4; h=0:100:...

1 día ago | 0

Answered

Solving a linear system of 1st order ODEs using the Forward Euler method and ode45

You were confusing time and x position. Try tf = 4; %final time You are integrating wrt time not x tspan = [0,tf]; h = .05;...

Solving a linear system of 1st order ODEs using the Forward Euler method and ode45

You were confusing time and x position. Try tf = 4; %final time You are integrating wrt time not x tspan = [0,tf]; h = .05;...

1 día ago | 0

| accepted

Answered

How can I solve this ode problem?

You get a singularity (divide by zero) when u = 60, giving infinite acceleration. You need to include a guard against this.

How can I solve this ode problem?

You get a singularity (divide by zero) when u = 60, giving infinite acceleration. You need to include a guard against this.

2 días ago | 1

| accepted

Answered

My function f(x) doesn't display (compute?) the result for when f = 0.

Replace diff(g) by gradient(g)

My function f(x) doesn't display (compute?) the result for when f = 0.

Replace diff(g) by gradient(g)

4 días ago | 1

Answered

Taking a descend interval

Insert tau = n+1-t; then raise 1/800 to the power tau.

Taking a descend interval

Insert tau = n+1-t; then raise 1/800 to the power tau.

4 días ago | 0

| accepted

Answered

Complex Sinwave to plot

Like this x = 0:0.1:4.56; p = zeros(1,numel(x)); q = zeros(1,numel(x)); for i = 1:numel(x) p(i) = fn(x(i)); q(i) =...

Complex Sinwave to plot

Like this x = 0:0.1:4.56; p = zeros(1,numel(x)); q = zeros(1,numel(x)); for i = 1:numel(x) p(i) = fn(x(i)); q(i) =...

5 días ago | 0

Answered

Extreme difference between the value of a function and the result in matlab

Must hit an overflow. Express it as: a=sqrt(4950000001); b=30000; r = (a/b)^2; y1 = 333.75+r*(11*r - b^2 -121 - 2/b^4)+5.5*...

Extreme difference between the value of a function and the result in matlab

Must hit an overflow. Express it as: a=sqrt(4950000001); b=30000; r = (a/b)^2; y1 = 333.75+r*(11*r - b^2 -121 - 2/b^4)+5.5*...

5 días ago | 1

Answered

Unable to perform assignment because the left and right sides have a different number of elements

Like this? % 1. Define Initial Conditions N = 50; % x_0 = 50*pi/180*randn(2,N); phi_0 = x_0(1,:...

Unable to perform assignment because the left and right sides have a different number of elements

Like this? % 1. Define Initial Conditions N = 50; % x_0 = 50*pi/180*randn(2,N); phi_0 = x_0(1,:...

7 días ago | 0

| accepted

Answered

euler method for solving system of ODE's 1st order

Simple Euler inaccurate for large step size. Reduce step size as in following and see if you get the output you expect: a=0; %...

euler method for solving system of ODE's 1st order

Simple Euler inaccurate for large step size. Reduce step size as in following and see if you get the output you expect: a=0; %...

9 días ago | 1

Answered

How to stop ODE(R4K) function when the value is close to 0?

Have you tried replacing u_p(i+1)=u_p(i)+h/6*(k1u_p+ 2*k2u_p + 2*k3u_p +k4u_p); with u_p(i+1)= max(u_p(i)+h/6*(k1u_p+ 2*k2u_p...

How to stop ODE(R4K) function when the value is close to 0?

Have you tried replacing u_p(i+1)=u_p(i)+h/6*(k1u_p+ 2*k2u_p + 2*k3u_p +k4u_p); with u_p(i+1)= max(u_p(i)+h/6*(k1u_p+ 2*k2u_p...

10 días ago | 0

Answered

how can i solve this problem and plotting?

I assume you want to find the values of a that make the integral = 75, for all values of x. if so, then the following should do...

how can i solve this problem and plotting?

I assume you want to find the values of a that make the integral = 75, for all values of x. if so, then the following should do...

10 días ago | 1

| accepted

Answered

speeding up my for loop

Is this any quicker? function y = divisors1(N) i = 1:floor(N/2); L = lcm(N,i); y = sum(L==N) + 1; e...

speeding up my for loop

Is this any quicker? function y = divisors1(N) i = 1:floor(N/2); L = lcm(N,i); y = sum(L==N) + 1; e...

10 días ago | 0

Answered

Mark the knee point on a graph

Calculate a vector of values of P = V.*I then choose the maximum. Something like: P = V.*I; indx = find(P==max(P)); Vp = V(in...

Mark the knee point on a graph

Calculate a vector of values of P = V.*I then choose the maximum. Something like: P = V.*I; indx = find(P==max(P)); Vp = V(in...

11 días ago | 0

| accepted

Answered

Discretising a size distribution function and area under the curve

You should have log(sigma)^2, not log(sigma^2). Don't forget the "dx" part when integrating the curve. mu = 0.015; % geometri...

Discretising a size distribution function and area under the curve

You should have log(sigma)^2, not log(sigma^2). Don't forget the "dx" part when integrating the curve. mu = 0.015; % geometri...

11 días ago | 1

Answered

ODE system initial condition results in infinity/NaN error. Initial conditions cannot be changed. How to evade?

Simply write your differential function as: fu_p = @(D_p,u_p) -18*muG*u_p/(rhoP*D_p^2) + g*(rhoP-rhoG)/rhoP; avoiding any expl...

ODE system initial condition results in infinity/NaN error. Initial conditions cannot be changed. How to evade?

Simply write your differential function as: fu_p = @(D_p,u_p) -18*muG*u_p/(rhoP*D_p^2) + g*(rhoP-rhoG)/rhoP; avoiding any expl...

12 días ago | 0

| accepted

Answered

Single bubble expansion equation

Try starting your bubble radius as 2*sigma/1.4, rather than 0.

Single bubble expansion equation

Try starting your bubble radius as 2*sigma/1.4, rather than 0.

13 días ago | 0

| accepted

Answered

Coupled rate ODEs with ode45

It can all be done in one script as follows. Because of the orders of magntude difference between the various concentrations th...

Coupled rate ODEs with ode45

It can all be done in one script as follows. Because of the orders of magntude difference between the various concentrations th...

13 días ago | 0

Answered

How can I call the highest order solution (e.g. x'') of an ode in another ode?

You can rearrange the equations as follows to get a consistent set: (you will need to use explicit multiplication where my eq...

How can I call the highest order solution (e.g. x'') of an ode in another ode?

You can rearrange the equations as follows to get a consistent set: (you will need to use explicit multiplication where my eq...

13 días ago | 0

| accepted

Answered

How can I make a loop that gives values in each iteration?

Why do you need a loop? There is just one zero between 2 and 8. Your values of w are not used in any meaningful way (they woul...

How can I make a loop that gives values in each iteration?

Why do you need a loop? There is just one zero between 2 and 8. Your values of w are not used in any meaningful way (they woul...

13 días ago | 0

Answered

How to use ODE 45 to generate a SIR model

Like so: alpha=1.99; beta=1; gamma=1/7; S=0.99; I=0.01; R=0.1; %tstart=0; %tend=100; y=[S,I,R]; tspan=0:1:100; [t,sol...

How to use ODE 45 to generate a SIR model

Like so: alpha=1.99; beta=1; gamma=1/7; S=0.99; I=0.01; R=0.1; %tstart=0; %tend=100; y=[S,I,R]; tspan=0:1:100; [t,sol...

14 días ago | 2

Answered

error in using the function fsolve to find steady state

Using the Optimization toolbox to solve these equations seems like using a sledgehammer to crack a nut! It is clear from the eq...

error in using the function fsolve to find steady state

Using the Optimization toolbox to solve these equations seems like using a sledgehammer to crack a nut! It is clear from the eq...

14 días ago | 0

Answered

I am trying to solve ODE having more than 1 dependent variable. but I am not able to solve it with dsolve function. please help me to find correct function to solve ODE.This is an mechanical engineering equation so it is bit complicated and lengthy

Here's a possible way using ode45. I've used arbitrary initial values for the three temperatures, so you will need to replace t...

I am trying to solve ODE having more than 1 dependent variable. but I am not able to solve it with dsolve function. please help me to find correct function to solve ODE.This is an mechanical engineering equation so it is bit complicated and lengthy

Here's a possible way using ode45. I've used arbitrary initial values for the three temperatures, so you will need to replace t...

14 días ago | 1

| accepted

Answered

MATLAB Newton Raphson Method with a function with array/matrix variables

You could do it like this f = @(x,g) g.*exp(x) - 1; df = @(x,g) g.*exp(x); g = [1 2 3 4 5]; for i= 1:numel(g) x0 = 0...

MATLAB Newton Raphson Method with a function with array/matrix variables

You could do it like this f = @(x,g) g.*exp(x) - 1; df = @(x,g) g.*exp(x); g = [1 2 3 4 5]; for i= 1:numel(g) x0 = 0...

14 días ago | 1

| accepted

Answered

When i try to create function error "Unable to perform assignment because the left and right sides have a different number of elements." comes up

Try n=-25:25; x3=zeros(1,length(n)); x3(n>=2 & n<=22)=exp(j*(0.5)).^(2:22);

When i try to create function error "Unable to perform assignment because the left and right sides have a different number of elements." comes up

Try n=-25:25; x3=zeros(1,length(n)); x3(n>=2 & n<=22)=exp(j*(0.5)).^(2:22);

14 días ago | 0

| accepted

Answered

Explicit Eulers Method for time advancement

T(i)^(n+1) This will raise T(i) to the (n+1)th power! You need another loop for time (say j = 1:something), then you can refer...

Explicit Eulers Method for time advancement

T(i)^(n+1) This will raise T(i) to the (n+1)th power! You need another loop for time (say j = 1:something), then you can refer...

15 días ago | 0