7
$\begingroup$

I'd like to use Table to generate a list of numbers that includes a gap. For instance, this accomplishes what I want:

α = π/2;
X1 = Table[-Q1 + α, {Q1, α, α/√3, -0.01}];
X2 = Table[-Q1 + α, {Q1, -2 α/√3, -2 α/√3 - 1/3, -0.01}];
X = Join[X1, X2];

However, I'd like to do this within one Table line, because I'd like to use Manipulate to run through the list X. Alternatively, is there a straightforward way to use Manipulate with the list X that I currently have. Either would be fine. Thanks.

$\endgroup$
  • $\begingroup$ As an alternative to the answer by @Johu, you can let a single Table variable go from start to finish with a constant step, but let the expression evaluates to Nothing when the variable is out of an interval. Nothing gets discarded. $\endgroup$ – BoLe Aug 4 '16 at 13:01
  • $\begingroup$ This might be useful. I'm trying to use the list within a DynamicModule, and I basically need a slider to run over the elements in the list X. I still haven't figured that out... $\endgroup$ – dpholmes Aug 4 '16 at 13:12
9
$\begingroup$

I would generate the list of parameters beforehand and use Table[expr,{i,{i1,i2,...}}]

α = π/2;
qList = Range[α, α/√3, -0.01] ~Join~ Range[-2 α/√3, -2 α/√3 - 1/3, -0.01];
X = Table[-Q1 + α, {Q1, qList}];
$\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.