Answered
Error with ode45 in line 89. Trying to use ode 45 to give data on a 4x4 state space matrix
M1=1; M2=1; K1=2; K2=2; B1=1; B2=1; x1_0=1; v1_0=1; x2_0=0; v2_0=1; %% equations q0=[ x1_0 v1_0 x2_0 v2_0]; dQdt = ...

3 years ago | 0

Answered
How to use fminbnd but with multiple variables
In the case above, your objective function is separable in the optimization variables. Thus you can solve two independent proble...

3 years ago | 1

Answered
How can I obtain all possible combinations of 3 decimals whose sum equals 1, without running into memory and space issues?
If you have some time, you can try I = 0:0.001:1. Why don't you use the code from the File Exchange ? I = 0:0.01:1; n = num...

3 years ago | 0

Answered
Help creating an array with uniformly distributed random numbers (row-wise) comprised between 0 and 1, with each column having a sum of 1
https://uk.mathworks.com/matlabcentral/fileexchange/9700-random-vectors-with-fixed-sum You cannot expect the usual uniform dist...

3 years ago | 1

| accepted

Answered
How can I input sum over in function depend on time?
Never make changes in the RK4 function. Changes have to be made in the call to RK4 and in f. tstart = 0; tend = 100; dt = 0....

3 years ago | 0

| accepted

Answered
Solving stokes flow use pde toolbox
The (simplified) Navier-Stokes equations need a special numerical treatment and cannot be solved by a general-purpose code like ...

3 years ago | 2

Answered
How do i fix the error that i am getting?
Remove the semicolon behind the line pivotColumns = rrefA(:,1:end-1); execute the code and see if it makes sense to insert the...

3 years ago | 0

| accepted

Answered
try to find hessian matrix
The vector of independent variables is (x1,x2,...,xn): syms i k n = 3; x = sym('x',[1 n]) f = n*log(k) - n*log(1/n*sum(x.^k)...

3 years ago | 0

Answered
Integration time step in ODE45 Matlab
If you use a two-element vector for tspan only giving the start and end time of integration, the values T(i+1)-T(i) (i=1,...,end...

3 years ago | 0

Answered
I am struggling to set a maximum value for a output for a function. I have nested my function in another but it is giving an error.
Instead of programming if-statements within the function routine and setting parameters depending on the actual time t, you shou...

3 years ago | 0

| accepted

Answered
Getting this error : Operator '==' is not supported for operands of type 'cell'. what should I do?
https://uk.mathworks.com/help/stateflow/ref/strcmp.html

3 years ago | 0

Answered
Problem with convergence using newtons method
Use PHI = matlabFunction(phi,'Vars',{n,k}) jacob_PHI = matlabFunction(jacob_phi,'Vars',{n,k}) n0 = -0.3; k0 = 3.4; instead ...

3 years ago | 0

| accepted

Answered
Iterative Process to find a variable in which two equations are equal and opposite
Here is at least one solution for h: % Equation Eo=1; Uo=1; Fc=1.03; Wc=2*pi*Fc; b=0.3; Ed=100; Ud=1; h0 = 10; fun = @...

3 years ago | 0

Answered
Error using Time dependant Boundary Conditions with PDEPE
If "time" is the array corresponding to the data matrix, use data_actual = interp1(time,data,t) and set pr = [data_actual(1)...

3 years ago | 0

| accepted

Answered
Solving nonlinear equation with parameter
Tau = 0:0.01:1; kc0 = 270; Ea1 = 21500; Ea2 = 121500; n = 0.63; eps = 0.52; Cch4 = 0.2; Temp = 800 + 273; kcmax = kc0*ex...

3 years ago | 0

| accepted

Answered
How do I generate numbers from an Exponential Distribution within Min and Max values?
pd = makedist('Exponential','mu', 1.5); n = 100; lb = 0.5; ub = 4.3; rv = zeros(n,1); i = 0; while i < n r = random(p...

3 years ago | 0

Answered
Index in position 2 exceeds array bounds
I already showed you how to solve "ode" as well as "ode1" simultaneously for D2p and D2q. This is necessary because both depend ...

3 years ago | 0

| accepted

Answered
Error due to integration
%filename ='Torque.xlsx'; %sheet = 'Averages'; %A = readtable(filename,'Sheet',sheet,'Range','A3:L32'); %A = table2array(A); ...

3 years ago | 0

| accepted

Answered
How do I fix "Index in position 2 exceeds array bounds (must not exceed 1)."
Before entering the loop after which the error message pops up, type size(gamma) size(sigma_g) size(g_omega_q_k_q) and chec...

3 years ago | 0

| accepted

Answered
optimization for nonlinear equation using fminunc
x0 = [1 1 1]; fun = @(x) x(1)*dsdt + x(2)*s.^x(3); f = @(x) sum(sum((fun(x) - p).^2)); x = fminsearch(f,x0) lhs = fun(x)

3 years ago | 0

| accepted

Answered
Trouble formulating Range Kutta
The expression [-ka3*A\[0; 1 ;0] zeros(3,1)] must be 6x6 instead of 3x2 in order to work for your system. And the numerical i...

3 years ago | 0

| accepted

Answered
Unable to perform assignment because the size of the left side is 10-by-1 and the size of the right side is 10-by-1-by-10.
In the assignments RHS(:,pp,gg) = (((1-alpha1(pp)... and RHS(:,pp,gg) = (((1-alpha2(pp)... the resulting term on the righ...

3 years ago | 1

Answered
Generate function handle for odesolver dynamically
Define your equations by a function instead of a function handle. In the function, you can make a loop in order to account for t...

3 years ago | 0

| accepted

Answered
Retrieve value from cell(array)
solution = fsolve(F,arrayfun(@(i)vertcat(X_sol{1,i}(1,1)),1:size(X_sol,2))) But you should avoid making your code too general b...

3 years ago | 0

| accepted

Answered
How to compute 8 days mean from one year data?
data_matrix = readtable('sample.csv'); data_matrix = table2array(data_matrix); n = floor(365/8); out_day = zeros(n+1,9); for...

3 years ago | 0

Answered
Runge-Kutta Integration 4th Order - Taylor Maccoll
% Isentropic exponent gamma = 1.4; % assumed shock anngle Theta_shock = 14.35; % Mach number M = 6; % Compute initial cond...

3 years ago | 0

Answered
I have a code, but it keeps saying "Supplied objective function must return a scalar value.'
I have a code, but it keeps saying "Supplied objective function must return a scalar value.' Yes, that's true. Your function "S...

3 years ago | 0

Answered
Unspecified number of dimension for ndgrid
https://uk.mathworks.com/matlabcentral/answers/372299-how-to-do-a-cycle-through-a-n-dimensional-grid-if-n-is-not-fixed

3 years ago | 0

| accepted

Answered
Not enough input arguments
You must return dCdt and dSdt at time t in function "SBR1": function dy = SBR1(t,y) C = y(1); S = y(2); ... % Calcu...

3 years ago | 0

Answered
Runge-Kutta 4th order Integration - Taylor-Maccoll
gamma = 1.4; % intitial values uR(y1) and uTheta(y2), behind the shock wave g0(1) = 0.9078; g0(2) = -0.1262; % assumed shock...

3 years ago | 0

Load more