0
$\begingroup$

I am trying to generate a plot for S2[w]. My code is below

L := 50
Umc := 4.31
Su[ω_, σ_, τ_] := (σ^2 *τ/π )*1/(1 \
+ (τ *ω)^2)
Sw[ω_, σ_, τ_] := (σ^2 *τ/(2*π \
))*(1 + 3*(τ* ω)^2)/(1 + (τ*ω)^2)^2

Ru[s_] := InverseFourierTransform[Su[ω, 1, L/Umc], ω, s]

S2 [ω_] := Integrate[Ru[s]*Cos[2*ω*s], {s, 0, Infinity}]

Plot[S2[ω] , {ω, 0, 1}]

I have no idea what I am doing wrong. The function outputs number for the prescribed range when I tested. Your help would be much appreciated. Thanks!

$\endgroup$
1
  • $\begingroup$ Change to Plot[Evaluate@S2[\[Omega]], {\[Omega], 0, 1}, PlotRange -> All] $\endgroup$
    – ciao
    Mar 23, 2014 at 0:37

1 Answer 1

3
$\begingroup$
Plot[Evaluate@S2[ω], {ω, 0, 1}, PlotRange -> All]

enter image description here

BTW, generally a bad idea to use symbols with capitalized initials - you risk clashing with built-in symbols...

$\endgroup$
6
  • $\begingroup$ thanks for the help...if I want to plot another function S3[w] on the same graph then can you please help me with this? I tried Plot[{Evaluate@S2[\[Omega]], Evaluate@S3[\[Omega]]}, {\[Omega], 0, 1}, PlotRange -> All] but it doesn't work. where S3[\[Omega]] = Integrate[Ru[s]*Cos[\[Omega]*s], {s, 0, Infinity}]...also I would like to have the x axis in log scale...can you please help with this? thanks $\endgroup$
    – Stoc
    Mar 23, 2014 at 1:09
  • $\begingroup$ @Stoc Evaluate should be placed at the first level inside the function with a Hold* attribute you wish to cancel (Plot in this case): Plot[Evaluate@{S2[\[Omega]], S3[\[Omega]]}, {\[Omega], 0, 1}, PlotRange -> All]. $\endgroup$ Mar 23, 2014 at 1:19
  • $\begingroup$ @AlexeyPopkov Thank you so much again....I have yet again one more problem, I am trying to do a LogLog plot and I am using: LogLogPlot[Evaluate@S2[\[Omega]], {\[Omega], 0, 1}] but there is an error...can you please help with this? sorry for the bother $\endgroup$
    – Stoc
    Mar 25, 2014 at 17:20
  • $\begingroup$ @AlexeyPopkov also, if I use your variant above (i.e., LogLogPlot[Evaluate@{S2[\[Omega]], S3[\[Omega]]}, {\[Omega], 0, 1}, PlotRange -> All]) for many plots then will it still work? I'll really appreciate the help...just need this result $\endgroup$
    – Stoc
    Mar 25, 2014 at 17:22
  • 1
    $\begingroup$ @Stoc Please read the error messages carefully, they contain key information what you are doing wrong and how to do it right. In the case of LogLogPlot you get the message "Range specification {ω,0,1} is not of the form {x, xmin, xmax} with xmin and xmax positive." which simply means that you must specify the plotting range with positive boundaries because Log is Real only for positive argument. So you should use something like LogLogPlot[Evaluate@S2[\[Omega]], {\[Omega], 0.01, 1}]. Answering your second question, yes, it should work. $\endgroup$ Mar 25, 2014 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.