Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #6377

Manipulate variables not getting evaluated

From Ken Levasseur <klevasseur@mac.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Manipulate variables not getting evaluated
Date 2011-11-11 10:05 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <j9is1j$8h6$1@smc.vnet.net> (permalink)

Show all headers | View raw


Hello

I'm trying to control, using Manipulate, which rows of a matrix are 
displayed.  But have run into a problem.   The code I annotate here is 
copied without comments below.   For this example, I'll use this 2 by 3 
matrix

A = {{1, 2, 3}, {4, 5, 6}};

The following works pretty much as I intend, although there is fixable 
problem if all boxes are unchecked.

Manipulate[
 Transpose[Transpose[A][[Select[Range[3], {a, b, c}[[#1]] & ]]]],
 Evaluate[Sequence @@ {{a, {True, False}}, {b, {True,
      False}}, {c, {True, False}}}]]

Now I want to do the same for larger matrices with various numbers of 
columns so I've tried generalizing as follows:

Number of columns:

M = 3;

This generates a list of M symbols:   col1, col2,=85

switchlist = (ToExpression[StringJoin["col", ToString[#1]]] & ) /@
   Range[M];

This generates a list of controllers for each symbol=85

switches = ({ToExpression[StringJoin["col", ToString[#1]]], {True,
       False}} & ) /@ Range[M];

Now I expected this to work, but it fails:

Manipulate[
 Transpose[Transpose[A][[Select[Range[M], switchlist[[#1]] & ]]]],
 Evaluate[Sequence @@ switches]]

The problem is that the symbols in switchlist don't get evaluated. 

Manipulate[switchlist, Evaluate[Sequence @@ switches]]

 I've tried using controllers like {{col1,True},{True,False}} and that doesn't make a difference.    Any idea why this fails?

Ken Levasseur
UMass Lowell


******************
Code only:


A = {{1, 2, 3}, {4, 5, 6}};

Manipulate[
 Transpose[Transpose[A][[Select[Range[3], {a, b, c}[[#1]] & ]]]],
 Evaluate[Sequence @@ {{a, {True, False}}, {b, {True,
      False}}, {c, {True, False}}}]]

M = 3;


switchlist = (ToExpression[StringJoin["col", ToString[#1]]] & ) /@
   Range[M];


switches = ({ToExpression[StringJoin["col", ToString[#1]]], {True,
       False}} & ) /@ Range[M];

Manipulate[
 Transpose[Transpose[A][[Select[Range[M], switchlist[[#1]] & ]]]],
 Evaluate[Sequence @@ switches]]


Manipulate[switchlist, Evaluate[Sequence @@ switches]]

Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Manipulate variables not getting evaluated Ken Levasseur <klevasseur@mac.com> - 2011-11-11 10:05 +0000
  Re: Manipulate variables not getting evaluated Armand Tamzarian <mike.honeychurch@gmail.com> - 2011-11-12 12:38 +0000

csiph-web