How can I make a graph that is based on time that has time in the equation?
1 次查看(过去 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!