here is my question. I have a range of parameters spanning in a given range, a={1,50},b={100,200} and c={300,500}. For every set of parameters I have an indexed vector like this (for a given set):


If for example a=20, b=120, c=350:

Input: v[20][120][350]
Output: {1,3,5}

I would like to tell the code: give me the element "i" of v . But if i write (for every set):


It returns me the error message

 Part 2 of {1,3,5} does not exist. >>

and not the number 3.

  • $\begingroup$ are your parameters predefined? or v is a function that generates the list? I think some fundamental information are still missing here. If the v vectors are already declared, then Part[v[20][120][350],2] should work. If they are not declared yet, why do you want to take the second element of something that doesn't exist yet? It's still not clear what you want to do. Maybe it's just me, but I also don't get what you mean with "for every set" $\endgroup$ – Fraccalo Jan 23 at 12:34
  • $\begingroup$ I solved a set of differential equations in a range of parameters predefined by me. From the solutions I declared different vectors depending on the same parameters. Now I want to find the element "i" of every vector (defined previously) to compare them with other elements of other vectors. It is a very stupid question, maybe I should put these lists in just another form but I don't understand hoe. $\endgroup$ – Orion Jan 23 at 12:53

I have to admit that this is a very weird way of storing lists, but maybe you just simplified your real code for providing an example here. Anyway:

v[a][b][c] = {1, 5, 9};




Both work for me (mathematica 12 on MacOS)

In an example:

v[3][1][5] = {1, 5, 9};



If you want to keep it generic you could do something like:

ElementOperation[v_, n_] := ACertainOperationOnV[v[[n]]]

ElementOperation[v[a][b][c], 2]


This approach can be scaled to as many v elements as you want, without need of declaring them in advance. However, if you could expand on what you need to achieve, we could provide you with a better answer.


Following from your comment: "Now I want to find the element "i" of every vector (defined previously) to compare them with other elements of other vectors. "

If you can restructure your code so that the vectors are in a list, you can easily access the i-th element of the list:

v[1][2][3] = {1, 2, 3};
v[4][5][6] = {4, 5, 6};
allV = {v[1][2][3], v[4][5][6]};
allV[[;; , 2]]


If you can't have the v vectors in a list, you could try something like the following (I can't stress enough how much I think this is a bad idea, but it's up to you):

Information[v, "SubValues"][[3, ;; , 2]][[;; , 2]]

{2, 5}

| improve this answer | |
  • $\begingroup$ Also for me work in this way, but if I fon't declare v[a][b][c]={1,5,9} it doesn't work. And I don't know how to declare v for every set of parameters, they are just given me in output. $\endgroup$ – Orion Jan 23 at 12:14
  • $\begingroup$ can you explain a bit more what you want to achieve, maybe with an example? $\endgroup$ – Fraccalo Jan 23 at 12:18
  • $\begingroup$ I tried to edit the question. $\endgroup$ – Orion Jan 23 at 12:26
    v = {1, 5, 9}
    Part[v, 2]

    Association[Thread[{a, b, c} -> {1, 5, 9}]][b]
| improve this answer | |
  • $\begingroup$ 1, 5, 9 are not the values of the parameters. a b and c span in a range I didn't specified. $\endgroup$ – Orion Jan 23 at 11:59
  • $\begingroup$ The reason for the error is that your function name is not standardized. $\endgroup$ – A little mouse on the pampas Jan 23 at 12:01
  • $\begingroup$ and how can I standardize function depending on parameters? $\endgroup$ – Orion Jan 23 at 12:04

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.