How to enable grid?

8 visualizaciones (últimos 30 días)
Atiqah Zakirah
Atiqah Zakirah el 17 de Mayo de 2017
Respondida: Ates Eltutar el 7 de Abr. de 2021
I'm trying to display grid lines on my figure using "grid on" but MATLAB keeps showing me there's an error at my line with "grid on". Anyone knows why this is so? I got the following code from MathWorks but it's not working.
x = rand(50,1);
y = rand(50,1);
scatter(x,y)
grid on

Respuestas (2)

Star Strider
Star Strider el 17 de Mayo de 2017
Your code runs for me without error.
Do you have a variable or user function of your own named grid?
To find out, run this from the Command Window:
which grid -all
The result should only be (for your version of MATLAB, I am running R2017a):
C:\Program Files\MATLAB\R2017a\toolbox\matlab\graph2d\grid.m
If you get anything else, that will tell you what the problem is. The solution is to rename your user function or variable to something else.

Ates Eltutar
Ates Eltutar el 7 de Abr. de 2021
Ok but besides code, how do i open grid in the figures section?

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by