5
$\begingroup$

I would like to produce a table with 2 coordinates, where a step for one coordinate depends on the value of another one. I tried to do this in the following way:

Step[j_] := Association[{0.01 -> 5, 0.03 -> 10}]
Table1 = Table[{j, k}, {j, 0.01, 0.03, 0.02}, {k, 1, 100, Step[j]}]

but I failed. Could you please show me how to do this?

$\endgroup$
2
  • 2
    $\begingroup$ Also: Table[{j, k}, {j, 0.01, 0.03, 0.02}, {k, 1, 50, If[j == 0.01, 5, 10]}] $\endgroup$
    – Michael E2
    Jul 1, 2019 at 19:30
  • 1
    $\begingroup$ And: Step[j_] := Association[{0.01 -> 5, 0.03 -> 10}][j] with the rest of your code. $\endgroup$
    – Michael E2
    Jul 2, 2019 at 3:45

1 Answer 1

5
$\begingroup$
step = Association[{0.01 -> 5, 0.03 -> 10}];
Table1 = Table[{j, k}, {j, 0.01, 0.03, 0.02}, {k, 1, 50, step[j]}];

TableForm[Table1, 
    TableDirections -> {Row, Row}, 
    TableHeadings -> {None, None, {"j", "k"}}] 

enter image description here

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.