Message Boards Message Boards

0
|
2281 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Why does Mathematica object when I use y[x_,t_] but not when I use just y?

Posted 1 year ago

I'm defining my function y, which is a function of x and t, below, as just y. Mathematica likes that fine, and prints graphs as I want. Below is the code Im using, which Mathematica is fine with:

ClearSystemCache[]
h=1; l=10; v=1;
y=Sum[(8h/(n^2Pi^2))(2Sin[n Pi/4]-Sin[n Pi/2])Sin[n Pi x/l]Cos[n Pi v*t/l],{n,1,40,1}];
y2=Table[Plot[y,{x,0,10}, AxesLabel->{"x","y[x,t]"}],{t,0,2l/v,.02l/v}]; ListAnimate[y2] 

However, the following code, which just uses y[x,t] in place of y in the definition for y, which should be okay, produces an error msg:

ClearSystemCache[]

    h=1; l=10; v=1;

    y[x_,t_]=Sum[(8h/(n^2Pi^2))(2Sin[n Pi/4]-Sin[n Pi/2])Sin[n Pi x/l]Cos[n Pi v*t/l],{n,1,40,1}];

    y2=Table[Plot[y,{x,0,10}, AxesLabel->{"x","y[x,t]"}],{t,0,2l/v,.02l/v}];

    ListAnimate[y2] 

Why is this?

POSTED BY: Lewis Jones
2 Replies
Posted 1 year ago
POSTED BY: Eric Rimbey

Instead of ClearSystemCache[] use ClearAll[y]

POSTED BY: Henrik Schachner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract