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,...

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,...

1 day ago | 0

| accepted

Answered

---- ------- ---- ------

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

---- ------- ---- ------

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

1 day 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...

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...

2 days 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...

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...

2 days 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:/...

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:/...

2 days 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

Saving all the variables from an ode45 Function

[tw1,yw1] = ode45('Newscript_VectorField',Timet1,Ic1,options) w = yw(:,1)*Yi11 + yw(:,2)*Yi12

3 days 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...

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...

3 days 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...

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...

4 days 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...

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...

4 days 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

Combining vectors [1 2 3 4 5] and [2 3 4 1 5] to [12 23 34 41 55]

v = 10*v1 + v2

4 days 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 ...

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 ...

5 days 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...

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...

8 days ago | 1

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...

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...

8 days 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' ...

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' ...

8 days ago | 1

| accepted

Answered

How to generate random orthogonal codes in matlab

mat2str(de2bi(randi([0,3],5,16)))

How to generate random orthogonal codes in matlab

mat2str(de2bi(randi([0,3],5,16)))

9 days 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...

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...

9 days ago | 1

Answered

How to calculate the distance

distmat = B(:,4:7)-repmat(A,4,1); dist = vecnorm(distmat.')

How to calculate the distance

distmat = B(:,4:7)-repmat(A,4,1); dist = vecnorm(distmat.')

10 days ago | 1

| accepted

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 ...

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 ...

10 days ago | 0

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...

"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...

10 days 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)

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)

11 days ago | 1

| accepted

Answered

Integration within particular range

idx = x>=2 && x<=3; xp = x(idx); yp = y(idx); value = trapz(xp,yp)

Integration within particular range

idx = x>=2 && x<=3; xp = x(idx); yp = y(idx); value = trapz(xp,yp)

11 days ago | 0

| accepted

Answered

Solve symbolic Sylvester-like equation

syms a x11 x12 x21 x22 b11 b12 b21 b22 A=[a+sym('1'), sym('2'); sym('3'),sym('1')]; X=[x11,x12;x21,x22]; B=[b11,b12;b21,b22];...

Solve symbolic Sylvester-like equation

syms a x11 x12 x21 x22 b11 b12 b21 b22 A=[a+sym('1'), sym('2'); sym('3'),sym('1')]; X=[x11,x12;x21,x22]; B=[b11,b12;b21,b22];...

11 days ago | 0

Answered

speed for loop in sum

function main x = linspace(-2,2,100); %some vector [X,XX] = meshgrid(x,x); %some matrix k = 0:20; a = 0.5; A0 = a...

speed for loop in sum

function main x = linspace(-2,2,100); %some vector [X,XX] = meshgrid(x,x); %some matrix k = 0:20; a = 0.5; A0 = a...

12 days ago | 1

| accepted

Answered

How to use lognrnd?

It is common to say that X is lognormally distributed with parameters mu and sigma if it has the pdf f(x) = 1/(x*sigma*sqrt(2*p...

How to use lognrnd?

It is common to say that X is lognormally distributed with parameters mu and sigma if it has the pdf f(x) = 1/(x*sigma*sqrt(2*p...

12 days ago | 0

| accepted

Answered

Numerical value for sum of bessel functions

k = 0:10; x = 3; A0 = sum((-1).^k.*x.^(2*k).*besselj(2*k,x)) If x is a vector, use A0 = arrayfun(@(x)sum((-1).^k.*x.^(2*k)....

Numerical value for sum of bessel functions

k = 0:10; x = 3; A0 = sum((-1).^k.*x.^(2*k).*besselj(2*k,x)) If x is a vector, use A0 = arrayfun(@(x)sum((-1).^k.*x.^(2*k)....

12 days ago | 1

| accepted

Answered

System of differential equations and fitting with lsqcurvefit

function main % loading Exp data CurrentDensity = xlsread('Modified_Current_density_all','Sheet1','A1:J1001'); Brightne...

System of differential equations and fitting with lsqcurvefit

function main % loading Exp data CurrentDensity = xlsread('Modified_Current_density_all','Sheet1','A1:J1001'); Brightne...

12 days ago | 0

Answered

HOW TO SOLVE TRANSCENDENTAL EQUATION

function main Enle0 = 1.0; Enle = fzero(@fun,Enle0) end function res = fun(Enle) Vc = 0.249; c = 3e8; m0 = 0....

HOW TO SOLVE TRANSCENDENTAL EQUATION

function main Enle0 = 1.0; Enle = fzero(@fun,Enle0) end function res = fun(Enle) Vc = 0.249; c = 3e8; m0 = 0....

12 days ago | 1

| accepted

Answered

Finding the 'n'-th derivative of a function containing 'n'

syms x k n = 10; diff(exp(-x)*x^(n+k),x,n)

Finding the 'n'-th derivative of a function containing 'n'

syms x k n = 10; diff(exp(-x)*x^(n+k),x,n)

15 days ago | 0

| accepted

Answered

how to create an vector contains 10000 random values that uniformly distributed with mean 1 and variance 10 ?

mean = 1.0; std = sqrt(10); N = 10000; u = (mean-sqrt(12)/2*std) + sqrt(12)*std*rand(N,1) u is uniformly distributed on [a:...

how to create an vector contains 10000 random values that uniformly distributed with mean 1 and variance 10 ?

mean = 1.0; std = sqrt(10); N = 10000; u = (mean-sqrt(12)/2*std) + sqrt(12)*std*rand(N,1) u is uniformly distributed on [a:...

16 days ago | 0

| accepted