i want to write equation in matlab

1 次查看(过去 30 天)
% 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.

采纳的回答

Walter Roberson
Walter Roberson 2021-4-25
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Price and Analyze Financial Instruments 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by