How can I make a graph that is based on time that has time in the equation?
2 ビュー (過去 30 日間)
古いコメントを表示
So here is my code:
if true
format long
a = 1
b = 3*10^-7
c = 5*10^-8
f0 = 4*10^9
sigma = 0.2
t0 = 0
tmax = 2*b
t = 6*10^-9
omega = 2*pi*f
omega0 = 2*pi*f0
yt = a*exp((-(t-b)^2)/((2*c)^2))
G = -2*pi*f*(pi*c^2*f + sqrt(-1)*b)
D = (((b-(sqrt(-1))*2*pi*c^2*f-t0)/(sqrt(2)*c)))
E = (((b-(sqrt(-1))*2*pi*c^2*f-tmax)/(sqrt(2)*c)))
Ff = sqrt(pi/2)*a*c*exp(G)*((-sqrt(-1)*(erfi(-sqrt(-1)*D)))-((-sqrt(-1)*(erfi(-sqrt(-1)*E)))))
Zf = ((1-(sigma/2))*Ff) + (sqrt(-1)*sqrt(pi/2)*((a*c*sigma)/4)*exp(-((2*pi*f+omega0)*(c^2*(2*pi*f+omega0)+2*sqrt(-1)*b))))*(-exp(4*pi*c^2*f*omega0+2*sqrt(-1)*b*omega0)*((-sqrt(-1)*erfi(((tmax-b+sqrt(-1)*c^2)*(2*pi*f-omega0))/(sqrt(2)*c)))-(-sqrt(-1)*erfi(((t0-b+sqrt(-1)*c^2)*(2*pi*f-omega0))/(sqrt(2)*c))))+(-sqrt(-1)*(erfi(((tmax-b+sqrt(-1)*c^2)*(2*pi*f+omega0))/(sqrt(-1)*c))))-(-sqrt(-1)*erfi(((t0-b+sqrt(-1)*c^2)*(2*pi*f+omega0))/(sqrt(-1)*c))))
% code
end
I have tried making:
if true
t = timeseries(t) % and also tried
t = 1:6*10^-7 % and then graphing
plot(t,yt)
% code
end
And I cant seem to get things to mesh correctly to get t to be returned as the value at that instant in time so that graph is returned. I've been scratching my head on this one for a while.
2 件のコメント
採用された回答
Star Strider
2015 年 8 月 5 日
There are several ways to create your time vector. Th easiest is likely linspace:
t = linspace(t0, tmax);
will create a vector of 100 points between (and including) ‘t0’ and ‘tmax’.
2 件のコメント
Star Strider
2015 年 8 月 5 日
My pleasure!
You can always change the number of points with a third argument to linspace. The default is 100.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!