Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Mathematica:input subscript value

  1. May 7, 2012 #1
    Hi all,
    i want to ask a very simple question.
    the data i have is:
    Code (Text):

    Subscript[d, 1]=3;
    Subscript[d, 2]=7;
    Subscript[d, 3]=0.6;
    Subscript[d, 4]=5;
    is there any way i can put the value faster like subscript[d,i],{i,4}={3,7,0.6,5}.

    Thanks advance,
  2. jcsd
  3. May 8, 2012 #2
    In[1]:= Table[(Subscript[d,i]={3,7,0.6,5}[]),{i,4}];Subscript[d,1]
    Out[2]= 3


    In[3]:= i=1;Map[(Subscript[d,i++]=#)&,{3,7,0.6,5}];Subscript[d,2]
    Out[5]= 7


    In[6]:= i=1;(Subscript[d,i++]=#)&/@{3,7,0.6,5};Subscript[d,3]
    Out[8]= 0.6
    Last edited: May 8, 2012
  4. May 8, 2012 #3
    Thanks Bill.:smile:
  5. May 8, 2012 #4

    one more thing.if my eq.is like
    Code (Text):

    how is it possible to simplify like previous one.

    Thanks advance
  6. May 8, 2012 #5
    In[1]:= (Subscript[d,#]=Subscript[e,#]/Subscript[f,#])&/@{1,2,3};Subscript[d,1]

    Out[1]= Subscript[e,1]/Subscript[f,1]

    Just one caution. One of the top handful of reasons people post "this doesn't work, what do I do?" is because they think the just MUST use subscripts and cannot figure out why it isn't working. Search here or in the Wolfram Student forum for Subscript and count the number of posts that match this description.

    Subscripts are not "ordinary variables with first class citizenship in Mathematica, despite how they look or how you think they might work." Without admitting that this has been a problem for decades, one of the Wolfram tech support people actually created a notebook to try to explain just a couple of the problems with this and how to try to get around them. Read the SubscriptedVariables101.nb here

    In Mathematica subscripts are a tar pit of problems and inconsistencies. Now and then I find. or see that someone else has found, a wildly new way that subscripts do not work for a completely different reason.

    Is it possible to make subscripts work? Sometimes. You have been warned. I hope it works out for you.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook