Couple of things going on. ClearSystemCache doesn't clear definitions. ClearAll would be the typical thing to do here, as Henrik pointed out. You should also familiarize yourself with Clear, Unset, Remove and others that you'll find in the documentation.
So, in your second attampt, y
still had a value assigned to it when you tried to define y[x_, t_]
. Let's look at a simpler example:
y=7;
y[x_] := 7 x;
You'll get a message like this: SetDelayed::write: Tag Integer in 7[x_] is Protected.
The integer it's referring to is the 7. Notice that what it was trying to define was actually 7[x_]
. To evaluate y[x_]
, it needs to first evaluate y
, which was 7
. Integers have the Protected
attribute, which prevents creating new definitions.
But even if you use ClearAll before your second attempt, you're still going to have problems. In this expression,
Plot[y, {x, 0, 10}, AxesLabel -> {"x", "y[x,t]"}]
the y
will now have DownValues, but not OwnValues. So, the y
as an expression won't evaluate to anything else, and Plot will produce an empty plot in that case. You're expecting this to plot the function that you are associating to y
in your head, but it's just plotting a literal symbol y
(and Plot is designed to produce an empty plot in that case).
So, you need to tell Plot the full expression that you want it to work with:
Plot[y[x, t], {x, 0, 10}, AxesLabel -> {"x", "y[x,t]"}]
(Of course, this still needs to be inside the Table so that t
gets replaced with actual values.)