Answered
Problem with simulating with SEIR variant
I get your results for I, Q and D. See them clearly by changing your Main section to; %SEIAQRD_Main to = 1; tf = 365; tspan...

6 years ago | 1

| accepted

Answered
cycle for integrating vector sections
Perhaps you should have something like: for i=1:4:length(Fi)-2 x=Fi(i:i+2); % +2 I need to integrate sections (3 values ​​...

6 years ago | 0

Answered
Find all possible unique combinations of weights of 3 assets
Here's a brute force and ignorance method: c = 0; n = []; for i=0:100 for j=0:100 for k=0:100 if...

6 years ago | 1

| accepted

Answered
How to code an ODE System with paramters depending on variables
You can include the body of each "extra" function directly in the main function: function dYdt = System(t,Y) i_L = Y(1...

6 years ago | 0

Answered
Conversion of a Fortran Equation to Matlab
This is the correponding MATLAB structure: for N = 1:TIMEF TCALC(N) = TEXP(1); for J = N:-1:1 ...

6 years ago | 0

| accepted

Answered
Branch Choice for Arguments of Complex Numbers in MATLAB
Can you use mod(angle, 2*pi) or mod(angle, -2*pi) as appropriate?

6 years ago | 0

Answered
I want to write a code for Fano lineshape fit.
Create a function that calculates the sum of squared differences (SS) between your function and the measured values, and then us...

6 years ago | 0

Answered
how to calculate the temperature of a thin rod using finite elements with the galerkin method? heat 1-d
I've attached a solution of the thin rod problem using the Galerkin FE approach. The attached is in Live Editor format so that...

6 years ago | 0

Answered
How to collapse within a column vector
One possibility is: x = 1:12; for i = 1:length(x)/3 p = 3*(i-1)+1; y(i) = sum(x(p:p+2)); end

6 years ago | 0

Answered
How to solve multiple DOF mass-spring linear system with attached resonators with ode45?
Something like this perhaps (but use your own data!): % Initial conditions u = zeros(length(tspan),length(x)); p = u; p(1,N/2...

6 years ago | 0

Answered
how to discretize a nonlinear model using Matlab
This is a simultaneous, linear system. You could do something like the following (replacing my arbitrary data with your actual ...

6 years ago | 0

| accepted

Answered
I need matlab code for optimization of the particle swarm (PSO)
Search pso on the Matlab File Exchange.

6 years ago | 0

| accepted

Answered
I am having a problem in doing assignment at Coursera
Your code has the limit 18 rather than 21. Given that, it produces the correct result. If you want the words true or false r...

6 years ago | 0

Answered
draw a simple complex function
How about: x0 = 1; y0 = 2; z0 = x0 + y0*i; R = abs(z0); theta = 0:1/360:2*pi; x = x0 + R*cos(theta); y = y0 + R*sin(th...

6 years ago | 0

Answered
Effect of Step Size ODE
Quite a few changes needed! F=@(t,y) 200*(y+0.01).^2*(0.2-y); %Initial Value Problem m = input ('Please choose the first m...

6 years ago | 0

Answered
Euler's method to plot orbital trajectory of comet
It's the vpa function slowing everything. There is no need for it here. Try the following: % Euler's Method % Initial condit...

6 years ago | 0

Answered
A problem with a "Recursive Function"
You could try the following: syms a b n=5; eqn=b==Recursive(n); a=solve(eqn,a); disp(a) function r=Recursive(m) ...

6 years ago | 0

| accepted

Answered
Generate manual repeatable signal for matlab
Like this? dt = 0.01; tf = 1.5; n = tf/dt + 1; for i = 1:n t(i) = (i-1)*dt; y(i) = wave(t(i)); end plot(t,y)...

6 years ago | 0

| accepted

Answered
Subplot in a for loop with different graphs
Something like this perhaps (though the labelling could be tidied up!): a = 0; b = 3; yt = @(t) 5.*exp(-t).*(-1 + sin(10.*t))...

6 years ago | 0

Answered
fixed bed adsorption column model-solving PDE-freundlish isotherm
The following works. I can't say if the result is sensible or not - you will need to judge that. I'm not convinced that the co...

6 years ago | 1

Answered
How to create bar plot with groups x-axis labels
Here's one way (there are almost certainly slicker ways!): % Arbitrary data x = 0:10:70; y = [ 5 2 3 7 8 1 7 4]; % Labels L...

6 years ago | 7

| accepted

Answered
Runge Kutta Loop and save array of results to workspace
Here's one way: p=1:0.2:5; h=0.15; x = 0:h:3; ...

6 years ago | 0

| accepted

Answered
Undefined unary operator '-' for input arguments of type 'string error
Why not just: y1 = [0,0,0,0,0,0,0,0,0,0,0,0.04,0.32,0.56,0.08,0,0,0,0,0,0,0,0,0,0]; y2 = [0,0.05,0.05,0.05,0,0.1,0,0,0.2,0.3,0...

6 years ago | 0

Answered
Using RK4 to solve an equation of one variable only
The code you found is, in fact, for just one dependent variable (y). It is also updating the independent variable (t). Try the ...

6 years ago | 1

| accepted

Answered
I would like to store store the change in temp in each node for each time step
I think the following does your desired calculations: %Parameters rho = 1; %density, kg/m^3 cp = 1; %specific heat, J/kgK K ...

6 years ago | 0

Answered
What did I do wrong here?
I answered this here: https://uk.mathworks.com/matlabcentral/answers/559760-how-to-do-this-problem#answer_461267?s_tid=prof_co...

6 years ago | 0

Answered
How to do this problem?
Try this: u0 = 5000; % This is the code that I wrote lambda = 0.03; pm = 9000; k = 100; f = @(t,p) lambda*p*(1-p./pm)-k; [...

6 years ago | 0

Answered
How to make an if condition where strings are involved?
Try replacing letter~=alphabet with ~any(strcmp(alphabet,letter))

6 years ago | 1

Answered
how to use reshape ?
If A is your 23043864x3 matrix, then B = reshape(A, 339, 203928); should work. Of course, you could simply use A where I've ...

6 years ago | 0

Answered
How to solve y''+y'-2y=x
Something like this perhaps: Y0 = [2 5]; % intial conditions xspan = [0 5]; % x-boundary values % ode solver [x, Y] = ...

6 years ago | 0

| accepted

Load more