I\'m trying to write a function what detect this relation between the variables I have got in the workspace:
v1 - fft(v2) = 0
Where v1, v2 are
You can use who() to programatically obtain a list of variables that currently exist. You can then use eval() to get their values. At that point, you can use a fairly trivial nested loop to iterate over all possible pairs, looking for that relationship.
Note 1: Using eval()
for "normal" programming is considered bad style; it should only really be used for meta-programming tasks like this.
Note 2: If you have N
variables in the workspace, there are N^2
ordered pairs. This may take a while to iterate over if N
is large.
Note 3: You're essentially looking for equality between variables, which may not be particularly reliable in floating-point.