Mathematica:input subscript value

  • Mathematica
  • Thread starter shafieza_garl
  • Start date
  • Tags
    Value
In summary, the data i have is:1) subscript[d,1]=3;2) subscript[d,2]=7;3) subscript[d,3]=0.6;4) 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.
  • #1
shafieza_garl
20
0
Hi all,
i want to ask a very simple question.
the data i have is:
Code:
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,
 
Physics news on Phys.org
  • #2
In[1]:= Table[(Subscript[d,i]={3,7,0.6,5}[]),{i,4}];Subscript[d,1]
Out[2]= 3

OR

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

OR

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

OR

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

OR

In[6]:= i=1;(Subscript[d,i++]=#)&/@{3,7,0.6,5};Subscript[d,3]
Out[8]= 0.6


one more thing.if my eq.is like
Code:
Subscript[d,1]=Subscript[e,1]/Subscript[f,1];
Subscript[d,2]=Subscript[e,2]/Subscript[f,2];
Subscript[d,3]=Subscript[e,3]/Subscript[f,3];
how is it possible to simplify like previous one.

Thanks advance
 
  • #5
shafieza_garl said:
one more thing.if my eq.is like
Code:
Subscript[d,1]=Subscript[e,1]/Subscript[f,1];
Subscript[d,2]=Subscript[e,2]/Subscript[f,2];
Subscript[d,3]=Subscript[e,3]/Subscript[f,3];
how is it possible to simplify like previous one.

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
http://forums.wolfram.com/student-support/topics/28271

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.
 

Related to Mathematica:input subscript value

1. What is the purpose of using subscripts in Mathematica?

Subscripts in Mathematica allow for the creation of variables or symbols with a specific index or label. This can be useful for organizing and manipulating data, particularly in scientific or mathematical contexts.

2. How do I input a subscript value in Mathematica?

To input a subscript value in Mathematica, you can use the Subscript function. For example, Subscript[x,1] will create a variable x with a subscript of 1, and you can then assign a value to that variable using the standard assignment operator (e.g. x1 = 5).

3. Can I use subscripts in calculations and equations in Mathematica?

Yes, subscripts can be used in calculations and equations in Mathematica. They can be treated as normal variables and can be manipulated using standard mathematical operations.

4. How can I change the appearance of subscripts in Mathematica?

The appearance of subscripts in Mathematica can be changed by adjusting the formatting options. For example, you can change the font, size, and color of subscripts by using the Format > Font menu.

5. Are there any limitations to using subscripts in Mathematica?

While subscripts can be useful, there are some limitations to consider. Subscripts cannot be used in function names, and they may cause issues when exporting data to other software. Additionally, it is important to use subscripts consistently and avoid using them as a substitute for proper variable naming conventions.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
414
  • Programming and Computer Science
Replies
6
Views
3K
Replies
11
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Back
Top