i want to write equation in matlab

3 visualizaciones (últimos 30 días)
Tlotlo Oepeng
Tlotlo Oepeng el 25 de Abr. de 2021
Respondida: Walter Roberson el 25 de Abr. de 2021
% ampiltude
function[sign]=amplitude(t,x,y)
sign = 2*A(x^2+y^2)*exp(-0.5*((r/p)^2+(t/T)^2));
end
% function
% theta
Theta = @(x,y)atan(y/x);
K=1;
U_txy = Amp(t+T/2,x,y)*exp(iS*Theta)*exp(i*K*t)+Amp(t-T/2,x,y)*exp(iS*Theta)*exp(-i*K*t);
i want to write the above eqautions in matlab.that is my atempt. code wont run. doubt its ok. the function is suspose to be the amplitude, sign.

Respuesta aceptada

Walter Roberson
Walter Roberson el 25 de Abr. de 2021
format long g
x = randn, y = randn, t = 1.2;
x =
0.377605597049117
y =
-1.54538132450563
U(x,y,t)
ans =
-1.62600857320088e-05 - 3.8121853905296e-06i 7.54974455191625e-06 - 1.31539198710771e-06i
function U_txy = U(x,y,t) %need this in order to have shared constants
K = 1;
A = 7;
rho = 0.3;
t0 = 0.81;
tau = 1.28;
S = -2.16;
Theta = @(x,y)atan2(y,x);
r = reshape(sqrt(x.^2+y.^2), [], 1);
th = reshape(Theta(x,y), [], 1);
U_txy = amplitude(r,t+t0/2).*exp(1i.*S.*th).*exp(1i*K*t) + ...
amplitude(r,t-t0/2).*exp(1i.*S.*th).*exp(-1i*K*t).*exp(1i.*th.*[-1 1]);
% amplitude
function sign = amplitude(r,t)
sign = A .* r.^abs(S) .*exp(-0.5*((r./rho).^2 + (t./tau).^2));
end
end

Más respuestas (0)

Categorías

Más información sobre Price and Analyze Financial Instruments en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by