0

How to give a shorter one or two line command without repetition (single variable change in a subroutine):

Rad = 0.2; r[th_] = Sin[th]^2 ; Plot[r[th], {th, 0, 3 Pi}] ; 

v = 0.  c1 = ParametricPlot3D[{r[th] Cos[th + v], c th, 
  r[th] Sin[th + v]}, {th, 0, 3 Pi}, PlotStyle -> Tube[Rad]]; 

v = 1; c2 = ParametricPlot3D[{r[th] Cos[th + v], c th, 
  r[th] Sin[th + v]}, {th, 0, 3 Pi}, PlotStyle -> Tube[Rad]];

v = 1.5; c3 = ParametricPlot3D[{r[th] Cos[th + v], c th, 
  r[th] Sin[th + v]}, {th, 0, 3 Pi}, PlotStyle -> Tube[Rad]];

v = 2; c4 = ParametricPlot3D[{r[th] Cos[th + v], c th, 
  r[th] Sin[th + v]}, {th, 0, 3 Pi}, PlotStyle -> Tube[Rad]]; 

v = 2.5;  c5 = ParametricPlot3D[{r[th] Cos[th + v], c th, 
  r[th] Sin[th + v]}, {th, 0, 3 Pi}, PlotStyle -> Tube[Rad]]; 

v = 3;  c6 = ParametricPlot3D[{r[th] Cos[th + v], c th, 
  r[th] Sin[th + v]}, {th, 0, 3 Pi}, PlotStyle -> Tube[Rad]];

v = 3.5; c7 = ParametricPlot3D[{r[th] Cos[th + v], c th, 
  r[th] Sin[th + v]}, {th, 0, 3 Pi}, PlotStyle -> Tube[Rad]]; 

v = 4;  c8 = ParametricPlot3D[{r[th] Cos[th + v], c th, 
  r[th] Sin[th + v]}, {th, 0, 3 Pi}, PlotStyle -> Tube[Rad]]; 

v = 4.5; c9 = ParametricPlot3D[{r[th] Cos[th + v], c th, 
  r[th] Sin[th + v]}, {th, 0, 3 Pi}, PlotStyle -> Tube[Rad]]; 

v = 5; c10 = ParametricPlot3D[{r[th] Cos[th + v], c th, 
  r[th] Sin[th + v]}, {th, 0, 3 Pi}, PlotStyle -> Tube[Rad]]; 

v = 5.5; c11 = ParametricPlot3D[{r[th] Cos[th + v], c th, 
  r[th] Sin[th + v]}, {th, 0, 3 Pi}, PlotStyle -> Tube[Rad]]; 

v = 6;  c12 = ParametricPlot3D[{r[th] Cos[th + v], c th, 
  r[th] Sin[th + v]}, {th, 0, 3 Pi}, PlotStyle -> Tube[Rad]];

v = 6.5;  c13 = ParametricPlot3D[{r[th] Cos[th + v], c th, 
  r[th] Sin[th + v]}, {th, 0, 3 Pi}, PlotStyle -> Tube[Rad]];  

Show[{c1, c2, c3, c4, c5, c6, c7, c8 , c9, c10, c11, c12, c13},
 PlotRange -> All, Boxed -> False, Axes -> None]
Histograms
  • 2,276
  • 12
  • 21
Narasimham
  • 3,160
  • 13
  • 26
  • Could you replace ">" with quadruple space in your code? – Kuba May 18 '15 at 10:05
  • 2
    …you couldn't use Table[] or Map[]? – J. M.'s missing motivation May 18 '15 at 10:08
  • r[th_] := Sin[th]^2; With[{c = .45, Rad = 0.2}, Show[ParametricPlot3D[{r[th] Cos[th + #], c th, r[th] Sin[th + #]}, {th, 0, 3 Pi}, PlotStyle -> Tube[Rad]] & /@ Range[0, 6.5, .5], PlotRange -> All, Boxed -> False, Axes -> None]] You also have a strange c in there for some reason ... Cos[th + v], c th, r[th] ... so I guessed c = .45 for lulz – Histograms May 18 '15 at 10:18
  • I have marked this as a duplicate. You've been here long enough that you should be able to figure out how to apply Table to your problem based on the examples therein. – Mr.Wizard May 18 '15 at 10:48
  • @ Histograms: Thanks. put in $c$ value..tranfero error ..makes helical pitch more. – Narasimham May 18 '15 at 11:01
  • Thanks all for these responses. – Narasimham May 18 '15 at 11:03

0 Answers0