Answered
1D Heat Equation Explicit Scheme (fixed)
With for i=0:0.1:50 you are trying to index variables with zero. However, Matlab's indexing starts at 1.

4 meses ago | 1

Answered
How to plot Homogeneous solution and Particular integral seperately of a second order differntial equation using ode45
ode45 just solves first order equations, so turn your second order equation into two first order ones, like so: y' = v v' = -4...

4 meses ago | 0

Answered
Trying to plot R_K 4th order, but keep getting straight line?
Check these equations F_sir = @(s,i,r) -a*s*i; % change the function as you desire G_sir = @(...

4 meses ago | 1

| accepted

Answered
Not enough input arguments; fzero function
Replace T_mix = fzero(fun,T_mix_0); by T_mix = fzero(@fun,T_mix_0);

4 meses ago | 1

Answered
I am trying to use the trapezoidal rule to compute the flow rate of fluid through a pipe.
I think it needs to be more like this: % Velocity distribution function of the pipe % Area = pi*r^2 % dA = 2*pi*r dr % Q = V...

4 meses ago | 0

| accepted

Answered
How to get area under the fit attained by Curve Fitting tool?
Try help trapz

4 meses ago | 0

Answered
Progressively slower performance and task constraints using matrix and loops
With these particular functions it's easy to precalculate the Jacobian function and do everything numerically (and quickly). Fo...

4 meses ago | 0

Answered
Local Stiffness Matrix Negative
How about replacing if i==2 & j==2 k=A(e)*E/(L/5); elseif i==2 & j==1 k=...

4 meses ago | 0

Answered
Save array values in a for loop
Try replacing error = max(abs(double(y1-z1(vx)))) with error(i) = max(abs(double(y1-z1(vx))));

4 meses ago | 0

| accepted

Answered
Solving a PDE with two variables using cank nicolson method
Matlab indices start at 1, so the loops i, j and K in the following for i=0:N for j=0:M for K=0:1 f(x,y...

4 meses ago | 0

Answered
Solving a System of 2nd Order Nonlinear ODEs
You haven't passed y and z to the funcion in function dydt=mbd(M,m,g,lc,k) Probably needs to be more like function dydt=mbd(t...

4 meses ago | 0

Answered
Can I comment only a section or part of a line?
Like this: x = linspace(0,2*pi,100); y1 = sin(x); y2 = cos(x); plot(x,y1,... % comment x,y2)

4 meses ago | 0

Answered
Adding subtitle to the plot
In Matlab 2018 try title({'Main title text';'subtitle text'}) (Note the curly brackets)

5 meses ago | 0

| accepted

Answered
Left-rotating a vector
You define B as a null vector so it doesn't have an "end". Try, simply A = [1,2,3,4,5]; B = [A(2:end) A(1)]

5 meses ago | 0

| accepted

Answered
How can I solve this error : Invalid text character. Check for unsupported symbol, invisible character, or pasting of non-ASCII characters.
This works for me: n=input('donner le nombre de points: '); k=0; for i=1:n u1=rand;u2=rand; x=2*u1; y=2*u2...

5 meses ago | 0

Answered
Lax-Wendroff method for advection equation with periodic boundary condition
If you make dt=0.1*h/a; instead of dt=0.95*h/a; your max error reduces to 0.0355.

5 meses ago | 0

Answered
I want to solve the unknown variable t1
Well, this gets it working, though who knows if it makes any sense!" A0 =500; D0=100; c1=5; c2=10; c3=10; c4=8; a=30; a2...

5 meses ago | 0

Answered
How to make convergence plot (error VS time step) in a log-log scale among four numerical methods and exact solution?
This should give you the right idea: %% 1st-order Adams-Bashforh Solution fun = @(t,y) (y); %Function f(t,y) y0 = 1; %Initial...

5 meses ago | 0

Answered
i need some help with finding the damping ratio
Use fzero: x = [12.73, 25.36, 37.99]; y = [0.77, 0.29, 0.11]/2; zeta = fzero(@(zeta) fn(zeta,y),0.5); disp(['zeta = ' nu...

5 meses ago | 0

Answered
How to make graph that plot between Analytical Solution (Exact Solution) and Numerical Method Solution?
After Y = exactY(t2) you probably need something like: plot(t2,Y2,t2,Y) legend('AM','Exact') However, you haven't supplied th...

5 meses ago | 0

| accepted

Answered
How to numerically solve and plot definite integral with variable upper limit
Like so: K= @(t) (sin(t)-t.*cos(t)).*sin(t); P = 0:0.1:3.1416; for i = 1:numel(P) V(i) = integral(K,0,P(i)); ...

5 meses ago | 0

| accepted

Answered
merge two matrices after odd rows
Here's one way: A=[1 1;1 1;1 1]; B=[2 3;4 5;6 7]; AB = [A B]'; C = reshape(AB,2,6)'

5 meses ago | 0

Answered
Hello, I am trying to solve the ODE but I have an error I do not understand how to solve. Would appreciate some help. Thank you!
Like this? %% ODE45_estimation % ------ Constants ------ % m = 1248.5; g = 9.81; W = m*g; S = 17.1; % ------ Time int...

5 meses ago | 0

Answered
plotting Solid of revolution of a function
How about: X = 0:0.1:pi; R = sin(X); [z,x,y] = cylinder(R); surf(x,y,z)

5 meses ago | 1

Answered
Split an array using specific points
Like this? Y = [5;2;3;6;7;9;5;5;6;3;8;7;74;9;63;47;10;3]; diiv = [5; 9; 15]; y1 = Y(1:diiv(1)); y2 = Y(diiv(1)+1:diiv(2)); ...

6 meses ago | 1

Answered
Algorithm for Fractional power calculation
How about using the Newton-Raphson algorithm. Here's the basic idea: % x^n = b % Let f(x) = x^n - b % dfdx(x) = n*x^(n-1) %...

6 meses ago | 0

Answered
Stochastic differential equation Gompertz plotting a graph
You have x(1) = 0, so log(x(1)) is -Inf, which means that subsequent values of x will be NaNs.

6 meses ago | 0

| accepted

Answered
Defining integration function in matlanb
Like this? % If Cp is a constant then the integral is just Cp*T % If it is a function of T, then define the function: Cp = @(...

6 meses ago | 0

Answered
Plotting and coding problems
More like this perhaps: T = 300:0.5:500; w = 0.224; Tc = 304.2; ...

6 meses ago | 0

Answered
I am getting error, "array indices must be positive or logical integer values". Please help
You need multiplication signs between n and (w1+k) in calculations of u and z: [X,Y] = meshgrid(-4:0.2:4); n=2; k=1; %n=1,...

6 meses ago | 0