Answered
Interrupt a while loop with functions if it takes too long
Is there a way of timing the iteration during its execution and break it? No. You could go into the function and time certain o...

2 years ago | 1

| accepted

Answered
How to solve the system of time dependent coupled PDE's?
ode23t seems to work for high Reynolds numbers. In case ode23t fails (e.g. for the low Reynolds number regime), I recommend the ...

2 years ago | 1

Answered
Problem with my gamma_water values not giving me the correct pressure using fsolve
Look at the curves and see what's happening. Your first equation has two solutions while your second has none: DelH = -1* (-917...

2 years ago | 0

Answered
An absolutely ascending sequence
x = 0:10; all(diff(x)>0)

2 years ago | 0

| accepted

Answered
Find zero of simple monotonic function where the independent variable can only be integer
If you know a lower integer value xl and an upper integer value xu with y(xl)*y(xu) < 0, you could do a binary search starting f...

2 years ago | 0

Answered
Model simulation Code for SEIR
seir_simulation() function seir_simulation() % Parameters beta = 0.3; % Effective contact rate without control sigma = 1/5; ...

2 years ago | 0

Answered
using loops and arrays to solve for variables in equations
You mean this ? x=zeros(5,1); vis=zeros(5,1); %strain rate epsUse=1e-14; Puse=1e9; PARAMS.R=8.314; %ideal gas constant %d...

2 years ago | 0

| accepted

Answered
How to use Matlab to find a pressure in a temperature and density spreadsheet using the nearest density value.
%Generate artificial data t = linspace(10,30, 25); p = linspace(1, 20, 20); [T,P] = ndgrid(t,p); d = exp(-((T-20).^2+(P-10)....

2 years ago | 0

Answered
Kolmogorov-Smirnov (KS) Test
From the documentation: h = kstest(x,Name,Value) returns a test decision for the one-sample Kolmogorov-Smirnov test with additi...

2 years ago | 0

Answered
Solving the hub location problem
You set % Renewal of population population = offspring; and offspring has only size 1x100 instead of 1x186. Thu...

2 years ago | 1

| accepted

Answered
Why does the value of tolerance stop at n=2 (third value of the iteration) within the while loop?
Maybe you mean tol = 1e-7 instead of tol = exp(-7) ? However: It's correct that MATLAB quits the while-loop after three val...

2 years ago | 1

Answered
Minimization linprog constraint no feasible solution
The last equality constraint says that you want 0*x1 + 0*x2 + 0*x3 + 0*x4 + 0*x5 + 0*x6 + 0*x7 + 0*x8 = 6.6, thus 0 = 6.6 ... ...

2 years ago | 0

| accepted

Answered
4th order Runge Kutta Method Differential System
Note that COne and CTwo are given in muF - thus they should be prescribed as 1000e-6 in your code, I guess. COne = 1000e-6; C...

2 years ago | 0

Answered
Error using odearguments Vector Length issue
s3 = s(3) s5 = s(5) instead of s3=(s) s5=s(4)

2 years ago | 0

| accepted

Answered
Newton Forward difference method
Three coding errors: % Confirmed case Sample data points (x, y) data = [ 1, 88; 2, 49; 3, 47; 4, 8; 5, 34; 6, 762; 7, 98; 8, ...

2 years ago | 0

| accepted

Answered
integral using "int" function
Your code to produce g1, g2 and g3 does not matter. You don't get analytic expressions for the antiderivatives of g1, g2 and g...

2 years ago | 0

Answered
Ode23 is not outputting solutions at the times I specified between t0 and tf in tspan=[t0, t1, t2..., tf]
If you use the "soln" structure as result, ode23 only respects start and end point from your tspan vector. After the integrator...

2 years ago | 0

| accepted

Answered
f(x) = x^2/3(3-x^2)(x-4). How do I enter this function in MATLAB?
Replace c = solve(fx); by c = solve(fx*x^(1/3)==0,'Maxdegree',3);

2 years ago | 0

Answered
Problem with integration: there is a pole on a contour
In the usual sense, your integral does not exist. But you can compute its principal value: syms z syms t real f = (z^2+3*z+2...

2 years ago | 2

Answered
Integral2 seems to substitute non-scalar values of variable into integrand. Why?
"integral2" usually calls the function to be integrated with matrices of the same size for t1 and t2 to make the necessary funct...

2 years ago | 2

| accepted

Answered
error when using lsqnonlin to function containing fzero function
"K" is a vector because "fraction" is a vector. Thus the "y" you compute in "denaturationfun" is a vector. But "fzero" cannot so...

2 years ago | 0

| accepted

Answered
I'm trying to solve jeffry hamel equation using RK4 but it's not giving output as expected.
s = 6; Kn = 0.1; U20 = -1; U2 = fsolve(@(U2)fun_shoot(U2,s,Kn),U20) [Y,Z] = fun_odes(U2,s); plot(Z(:,1),Y) xlabel('U') yl...

2 years ago | 1

Answered
Generalised solution to a n-order system of equations
Here is my code, that provies a range of answers from a to b, inclusive. Besides that you shouldn't give the same names to the ...

2 years ago | 0

Answered
Unconstrained minimisation problem with a complicated range
I'll formulate the problem for one property - a generalization to three properties is obvious. I'll assume that each of the 3*N...

2 years ago | 0

Answered
I'm trying to solve a 2nd order ode with ode45, but have no idea where to start.
After dividing your equation by t, you can just follow the example Solve Nonstiff Equation under https://uk.mathworks.com/hel...

2 years ago | 0

Answered
How to solve for 1D non homogenous ODE by Finite element method
I usually set A(1,1) = 1, F(1) = 0, A(N+1,N+1) = 1, F(N+1) = 2 and only loop from 2 to N here: %%%% Assembling %%%% for i=1:...

2 years ago | 0

Answered
How do I change my scalars to fit my normpdf?
xq = 0:100; mu = [25, 50].'; sigma = [5, 10].'; ndist = 1./(sigma*sqrt(2*pi)).*exp(-((xq-mu)./sigma).^2); plot(xq,ndist) g...

2 years ago | 1

| accepted

Answered
newton raphson for nonlinear heat equation scheme
Why don't you use "pdepe" ? Ten lines of code maximum, and you are done. To get rid of the error in the above code, replace % ...

2 years ago | 0

Answered
How to quantify shape similarity between two vectors.
Shift the curves by their means first so that the means of all objects lie in the origin (0). This will remove translational dif...

2 years ago | 0

Answered
input appears to be a function and variable and exceeds the number of array elements???
You define a string of length 59 named "input". Then you want to use "input" as the MATLAB command to request user input for "ag...

2 years ago | 0

Load more