0
$\begingroup$

I have a table of four insoluble equations, fceq, in terms of unassigned variables,

Subscript[fc, i], Subscript[μ, i]. 

I am using contour plots to visualise them:

cplots = Table[ContourPlot[Evaluate[fceq[[i]]], {Subscript[fc, i], 0, 
1}, {Subscript[μ, i], 1, 3.8}, PlotPoints -> 260], {i, 1, 4}]

That works fine but it has an unpleasant side effect. After running this, printing Subscript[fc, 1], for example, returns

Charting`Private`pvar$727158 

instead of simply fc_1, and similarly for mu_1. I want to remove these assignments so I can use these variables again, but Clear[Subscript[fc, 1]] doesn't work. What's going on? Thanks!

$\endgroup$
  • $\begingroup$ This is a good reason not to use subscripts except for display purposes. It leads to no end of headaches otherwise. $\endgroup$ – J. M. will be back soon Mar 24 '18 at 16:01
  • $\begingroup$ I agree! I usually avoid subs but in my current work I have lots of tables of equations and I couldn't figure out how to automatically index variables without using subs. Is there a way to do, e.g. Table[xi[t]-> i Sin[t],{i,1,imax}] such that the loop knows to isolate the 'i' in 'xi' and change it with the index? I want the output to be {x1[t]->1 Sin[t], x2[t]->2 Sin[t], ....} This is straightforward if the 'i' is dropped to a subscript but then all the associated problems with subs show up. Where's the happy medium? Thanks. $\endgroup$ – dr_strangeloop Mar 25 '18 at 0:30
  • $\begingroup$ If you must: Table[x[i][t] -> i Sin[t], {i, 1, imax}]. $\endgroup$ – J. M. will be back soon Mar 25 '18 at 1:01
1
$\begingroup$

Simple answer: I realised I can use Unset.

Subscript[fc, 1]=.

Then Subscript[fc, 1] simply returns fc_1 as required.

$\endgroup$
0
$\begingroup$

I think this issue is worth reporting to support. As a workaround, you could use Block. For example, without the Block:

Subscript[fc, 1]
cplots = Table[ContourPlot[Sin[Subscript[fc, i] Subscript[μ, i]],{Subscript[fc, i],0,1},{Subscript[μ, i],1,3.8}],{i,1,4}];
Subscript[fc, 1]

Subscript[fc, 1]

Charting`Private`pvar$23375

Using Block:

Clear[Subscript]
Subscript[fc, 1]
Block[{Subscript},
    cplots = Table[ContourPlot[Sin[Subscript[fc, i] Subscript[μ, i]],{Subscript[fc, i],0,1},{Subscript[μ, i],1,3.8}],{i,1,4}];
]
Subscript[fc, 1]

Subscript[fc, 1]

Subscript[fc, 1]

$\endgroup$

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.