1
$\begingroup$

Why doesn't the assignment with T work within the plot function? It seems like T is being evaluated as a constant. When I place the assignment T = 10000/(1 + x/100) outside the plot function, it works.

LogLinearPlot[{20 Log[10, T = 10000/(1 + x/100)], 
  20 Log[10, T/(1 + T)]}, {x, 1, 10^10}, GridLines -> Automatic]

enter image description here

This is the expected result:

enter image description here

$\endgroup$

2 Answers 2

4
$\begingroup$
$Version

(* "13.3.1 for Mac OS X ARM (64-bit) (July 24, 2023)" *)

Clear["Global`*"]

Attributes[LogLinearPlot]

(* {HoldAll, Protected, ReadProtected} *)

Whenever you have problems with a plot, check on whether Evaluate helps (because of the HoldAll attribute).

LogLinearPlot[
 Evaluate@{20 Log[10, T = 10000/(1 + x/100)], 20 Log[10, T/(1 + T)]},
 {x, 1, 10^10},
 GridLines -> Automatic,
 PlotStyle -> {Automatic, Dashed}]

enter image description here

$\endgroup$
3
$\begingroup$

You could define T within With:

With[{T = 10000/(1 + x/100)},
 LogLinearPlot[{
   20 Log[10, T],
   20 Log[10, T/(1 + T)]}, {x, 1, 10^10},
  GridLines -> Automatic,
  PlotLegends -> {"20 Log[10,T]", "20 Log[10,T/(1+T)]"},
  PlotStyle -> {Automatic, Dashed}]]

enter image description here

$\endgroup$

Your Answer

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

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