MATLAB: Plotting a 2D “Time Snapshot”

MATLABplotting

Hello. I am having trouble plotting a 2D "time snapshot" of a solution to a parabolic heat equation. The mesh plot seen near the bottom of my code works like a charm. However, I am supposed to try and plot a 2D "time snapshot" at time t = 20, so essentially just taking a slice of my 3D mesh. I am unsure how to do this. I have tried numerous things and nothing seems to be working. One of my classmates was able to use plot(:,401); to get his to work, where 401 is the final n iterate. This does not seem to work for me though. I get an error about an undefined function or variable with plot. From what I can tell, it does not like the semi-colon. I am not sure why this is a problem for me and not him, as our code is essentially the same. If anyone is able to show me how to make this 2D plot I would greatly appreciate it. A photo of my code is below:
Screen Shot 2019-04-28 at 10.45.05 PM.png

Best Answer

plot(t,u(20,:))
The one you are trying:
plot(:,401); % this is wrong
YOu have not specified the variable there. It should be
plot(u(:,401))