0
$\begingroup$

This question already has an answer here:

I want to plot the following function, where Rb is the variable (that has to be on the x-axis):

y[Rb]:=2*fin*(2*T*Ud - ((Ud)/(fin)) + ((Uin*Sin[2*Pi*fin*T])/(2*Pi*fin)) + 
   c*Rb*(2*Ud - Uin)*(Exp[-((T)/(c*Rb))] - 1))

Now Ud,fin, Uin and care constants, for example

Ud = 0.7, fin = 50, Uin = 5,  c = 470*10^(-6)

But to find T I need to solve:

FindRoot[
 Abs[Uin*Sin[2*Pi*fin*T - (Pi/2)]] - 2*Ud == (Uin - 2*Ud)*Exp[-T/(c*Rb)]
 , {T, 1/(4*fin), 1/(2*fin)}
 , WorkingPrecision -> 20
 ]

Now how can I plot the function y[Rb] while varying Rb?

$\endgroup$

marked as duplicate by Henrik Schumacher, m_goldberg plotting Jun 20 '18 at 13:04

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2
$\begingroup$

Here is what you can do:

Define Constants:

Ud = 7/10; fin = 50; Uin = 5; c = 470*10^(-6);

Define T as a function of Rb. Call it tr[Rb]

tr[Rb_?NumericQ] := 
 T /. FindRoot[
   Abs[Uin*Sin[2*Pi*fin*T - (Pi/2)]] - 2*Ud == (Uin - 2*Ud)*
     Exp[-T/(c*Rb)], {T, 1/(4*fin), 1/(2*fin)}, 
   WorkingPrecision -> 20]

Define y[Rb] with tr[Rb] instead of T

y[Rb_] := 
 2*fin*(2*tr[Rb]*
     Ud - ((Ud)/(fin)) + ((Uin*Sin[2*Pi*fin*tr[Rb]])/(2*Pi*fin)) + 
    c*Rb*(2*Ud - Uin)*(Exp[-((tr[Rb])/(c*Rb))] - 1))

Plot y[Rb]. Notice that you get WorkingPrecision warnings. This has to be looked into to see where the precision is getting lost.

Plot[y[Rb], {Rb, 1, 10}]

enter image description here

$\endgroup$
0
$\begingroup$

You could solve for Rb

RbT = Solve[Abs[Uin*Sin[2*Pi*fin*T - (Pi/2)]] - 2*Ud == (Uin -2*Ud)*Exp[-T/(c*Rb)], Rb][[1]]
ParametricPlot[{Rb, y[Rb]} /. RbT, {T, 1/(4*fin), 1/(2*fin)},AspectRatio -> 1]

Unfortunately the Plot is empty, probably because RbT is complex!

$\endgroup$
  • $\begingroup$ T follows from the equation I stated $\endgroup$ – asd Jun 20 '18 at 8:26
  • $\begingroup$ You gave some values for T in the FindRoot command. These values I used in the ParametricPlot... $\endgroup$ – Ulrich Neumann Jun 20 '18 at 8:37
  • $\begingroup$ What range Rb you expect? $\endgroup$ – Ulrich Neumann Jun 20 '18 at 8:51

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