How can I make a graph that is based on time that has time in the equation?

3 views (last 30 days)
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 Comments
imarquez
imarquez on 5 Aug 2015
Ok how about this then, I want to be able to graph from t0 to tmax. Can I somehow plot that based on my existing code?

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 5 Aug 2015
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 Comments
imarquez
imarquez on 5 Aug 2015
That is exactly what I had been looking for! Thank you so much! I had been trying to figure out a way to make that work for a while now
Star Strider
Star Strider on 5 Aug 2015
My pleasure!
You can always change the number of points with a third argument to linspace. The default is 100.

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!