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
Azzi Abdelmalek
Azzi Abdelmalek 2015년 8월 5일
[based on time that has time] It's difficult to understand!
imarquez
imarquez 2015년 8월 5일
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?

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
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
imarquez
imarquez 2015년 8월 5일
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 2015년 8월 5일
My pleasure!
You can always change the number of points with a third argument to linspace. The default is 100.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by