I am trying to run a simple live script:
x1=linspace(-pi, pi, 20);
x2=linspace(-10, 10, 30);
[X1, X2]=meshgrid(x1, x2);
Z = cos(X1).*X2;
mesh(X1, X2, Z)
In the beginning, clicking 'Run Section' will run the code correctly. At that time, the script has not been saved yet. So the script's name was 'untitled.mlx'. Then I saved the script as 'mesh.mlx'. Now, clicking 'Run Section' has the red error: Attempt to execute a SCRIPT mesh as a function: /MATLAB Drive/mesh
Why no error before the live script was saved and error afterwards? My screenshot is attached.
Thank you very much for your help. I greatly appreciate it.