1
$\begingroup$

I manage to plot strn[t] and sig[t] where sig[t] is the solution from my DSolve. However, when I want to ParametricPlot sig[t] vs strn[t], I failed to do it as the parametric plot does not show anything.

strn[t] = t*0.00025;
modulus = 20000;
sol1 = DSolve[{D[strn[t], t] == D[sig[t], t]/modulus, sig[0] == 0}, sig[t], t]
Plot[strn[t], {t, 0, 100}]
Plot[sig[t] /. sol1, {t, 0, 100}]
ParametricPlot[{sig[t] /. sol1, strn[t]}, {t, 0, 10}]

Can someone please tell me why?

$\endgroup$
  • 3
    $\begingroup$ You need to use sig[t] /. First@sol1. $\endgroup$ – b.gates.you.know.what Jun 25 '13 at 16:39
  • $\begingroup$ @b.gatessucks please post that as an answer. $\endgroup$ – Verbeia Jun 25 '13 at 21:09
  • $\begingroup$ Def. a function in the most basic case should look: " f[x_] := ". The underscore is missing. For every numerical value of t in the func strn we get numerical value and the derivative of any number is 0 and I don't really see the need to define a function and then pass an argument - in every case you end up with 0. Also I think, as a general rule, you should try to use less confusing naming convention for your functions. Are we using Sign[x], the built-in function, or a generic sig[x] function. As for comment above me - plotting it using the rule you mentioned doesn't produce anything. $\endgroup$ – Sektor Jun 25 '13 at 21:19
  • $\begingroup$ Thx for all the help. However, I still cannot plot sig[t] Vs strn[t]. The first two plots show that sig[t] and strn[t] can actually be plotted. Since the range of strn [t] is from 0 to 0.025 while range of sig[t] is from 0 to 500, does it means that parametric plot cannot be used? because so far i see in the help related to plot range, all of the plot using an approximately equal range. $\endgroup$ – Martin Wijaya Jun 26 '13 at 5:53
  • 1
    $\begingroup$ Your ParametricPlot is working, but the aspect ratio is tiny. Try using the option AspectRatio -> 1 $\endgroup$ – Simon Woods Jun 26 '13 at 8:22
2
$\begingroup$

Let me first answer why it is happening and then I shall give you the solution. Dsolve (and Solve also) return a table of all possible solutions. For your case the solution is unique, so it is a table with one element. You can check it by

sig[t] /. sol1

You see the answer is {5. t} not 5. t. When you put this this with Plot there is no problem. It is like

Plot[{5. t},{t,0,100}]

and it gives a nice plot. But with ParametricPlot it doesn't go so smooth. In this case the structure should be like

ParametricPlot[{x[t],y[t]},{t,0,100}]

but in your case it becomes like

ParametricPlot[{{x[t]},y[t]},{t,0,100}]
                 \_^_/

and hence it fails to plot anything.

The solution is quite easy. Use

sig[t] /. sol1[[1]]

You see now it returns 5. t. And your ParametricPlot will give

strn[t] = t*0.00025;
modulus = 20000;
sol1 = DSolve[{D[strn[t], t] == D[sig[t], t]/modulus, sig[0] == 0}, sig[t], t];
ParametricPlot[{sig[t] /. sol1[[1]], strn[t]}, {t, 0, 10}, AspectRatio -> 1]

plot

This will be more clear if you use a second order differential (or quadratic) equation. There you will have two solutions and then you have to specify which solution you want to use sol1[[1]] or sol1[[2]] for a single plotting.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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