i want to write equation in matlab

조회 수: 1 (최근 30일)
Tlotlo Oepeng
Tlotlo Oepeng 2021년 4월 25일
답변: Walter Roberson 2021년 4월 25일
% 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