Answered
Solvin Differential Algebraic Equations
function main %gaslift systems network tspan = [0:1:60]; % The script for gas lift network model defining initial condi...

7 years ago | 0

| accepted

Answered
Problems with numerical integration with 2 variables
function main Result = integral(@fun,0,pi/2) end function funret = fun(theta) n = numel(theta); funret = zeros(n,1)...

7 years ago | 0

| accepted

Answered
How do you get ten random values between -pi/2 and pi/2
theta = -pi/2 + rand(10,1)*pi

7 years ago | 0

Answered
How do I differentiate this function?
syms Z K gamma eta alpha NRC EOS1 v X R EOS2 NRM Y= Z*K^gamma*((1-eta)*((1-alpha)*NRC^EOS1+alpha*(X^v+R^v)^(EOS1/v))^(EOS2/EOS...

7 years ago | 0

| accepted

Answered
Tensor product of three matrices
M = kron(A,kron(B,C)) or M = kron(kron(A,B),C)

7 years ago | 1

| accepted

Answered
How do I assign part of a matrix to be a variable
A1 = A(1:3,:); A2 = A(4:6,:); A3 = A(7:9,:);

7 years ago | 0

Answered
Solving partial differential system
s= [-v*DuDx(1)-psi*km*(qe-u(2)); km*(qe-u(2))]; function [pl,ql,pr,qr] = pdex4bc(xl,ul,xr,ur,t) Q=2.5; %mL min^-1 A_c=1.96e...

7 years ago | 1

| accepted

Answered
I need matlab code for cot(x) Taylor Polynomial Function
f = @(x)cot(x); a = 5*pi/8; P0 = @(x)f(a)*ones(size(x)); P1 = @(x)f(a)+(- f(a).^2 - 1).*(x-a); P2 = @(x) f(a)+(- f(a).^2 -...

7 years ago | 0

Answered
Integro-differential systems
Solve d(psi)/dt = x(t), psi(0)=0 dx/dt = psi(t) - x(t), x(0) = ? Best wishes Torsten.

7 years ago | 2

Answered
PDEPE boundary condition outputting odd results.
function main m = 0; tspan = linspace(0,365*20*86400,21); xmesh = linspace(0,20,201); sol = pdepe(m,@pdefun,@icfun,...

7 years ago | 0

| accepted

Answered
Need help with the integral
format long I = 0.0; Iexact = 0.904524237900272; eps = 1e-15; n = 0; while abs(I-Iexact) > eps I = I + (-1)^n/(factorial(...

7 years ago | 0

| accepted

Answered
Generate random number from a two-parameter exponential distribution
gam = ...; lambda = ...; n = 100; x = gam - log(1-rand(n,1))/lambda give you 100 random numbers distributed according to you...

7 years ago | 0

| accepted

Answered
how to run optimisation problem
Use fmincon with objective function f = @(x)(R'*x)/sqrt(x'*sigma*x) and linear constraint Aeq = ones(size(x)) beq = 1 Best...

7 years ago | 0

Answered
How to take the fourth derivative of a reflectance graph
If you have the signal processing toolbox licenced, use "sgolay" and "sgolayfilt". Or download from the file exchange: https:/...

7 years ago | 0

| accepted

Answered
Saving all the variables from an ode45 Function
[tw1,yw1] = ode45('Newscript_VectorField',Timet1,Ic1,options) w = yw(:,1)*Yi11 + yw(:,2)*Yi12

7 years ago | 1

Answered
How to automatically constrain some of the unknown values in an optimization problem?
If you know in advance which elements of the x-vector are grouped together, you can simply use Aeq and beq to define the equalit...

7 years ago | 1

| accepted

Answered
Too many input arguments - Fminsearch
function fmin x0=0; %parâmetro de valor inicial para a condição options=optimset('Display','iter','TolFun',0.1) [x]=fmi...

7 years ago | 0

Answered
Error in while loop
Do you want a different value for B for each minor, i.e. B(i) instead of B ? Then use function IsStable(polynomial) if AllNon...

7 years ago | 1

| accepted

Answered
Combining vectors [1 2 3 4 5] and [2 3 4 1 5] to [12 23 34 41 55]
v = 10*v1 + v2

7 years ago | 0

| accepted

Answered
Set up an OR argument for equation
v = (xdot_1-xdot_2)).*(sign(x1-x2-gap)+1)/2; if v > 0 fp = (k_inp*(x1-x2-gap)+c_inp*(xdot_1-xdot_2)).*(sign(x1-x2-gap)+1)/2 ...

7 years ago | 1

| accepted

Answered
distance between two points
You mean "where each row indicates the XYZ coordinates of a point" ? And you want to calculate the distance between the correspo...

7 years ago | 2

Answered
Correct formulation for a fmincon problem
The vector of unknowns for fmincon will be Uvec = [u1(t0),u2(t0),u3(t0),u4(t0),u5(t0),u1(t2),u2(t2),u3(t2),u4(t2),u5(t2),...,u1...

7 years ago | 0

Answered
ode45 code not running and need help imputing my boundary conditions
function main y0=zeros(7,1); y0(1) = 0; % f y0(2) = 0; % f' y0(3) = 0; % f'' y0(4) = 0; % theta y0(5) = 0; % theta' ...

7 years ago | 1

| accepted

Answered
How to generate random orthogonal codes in matlab
mat2str(de2bi(randi([0,3],5,16)))

7 years ago | 0

| accepted

Answered
plotting profiles from differential equations
function dFTdV = Reactor3(V,FT) %Reactor3 function is used to obtain mass and energy balances across the %reactor F = FT(1...

7 years ago | 1

Answered
How to calculate the distance
distmat = B(:,4:7)-repmat(A,4,1); dist = vecnorm(distmat.')

7 years ago | 1

| accepted

Answered
trouble in integral solving [SOLVED]
q = vpa ( int(fun,[-Inf Inf]) )

7 years ago | 0

Answered
splitting real and imaginary part of a complex equation in order to generate two nonlinear equations to solve for two unknown real constants
Z0 = 50; Y0 = 1/Z0; e_inf = 4.6; % optical permittivity at high frequencies e_s = 78.3; % static permittivity ...

7 years ago | 0

| accepted

Answered
"The boundary condition function BCFUN should return a column vector of length..." ERROR USING BVP4C
As initial condition, you give a row vector of ones of length 432. So in ex1ode, bvp4c will give you a vector of length 432 for...

7 years ago | 1

Answered
Finite Integral with periodic values of x
idx = (x>=0.3 & x<=4.5); xp = x(idx); yp = y(idx); F = cumtrapz(xp,yp); F = F(end) - F; plot(xp,F)

7 years ago | 1

| accepted

Load more