In Matlab, is there a way in increase the size of a grid in a figure?

7 次查看(过去 30 天)
I am trying to create a sudoku puzzle in a figure and am using a grid. However, when I run the program, the figure is extremely small and I always have to manually make the figure bigger in order to the sudoku to display properly. This is how is displays:
This is how I want it to display:
This is my code for creating the sudoku figure:
{function dispSudoku(ingrid)
checker = [.8 .8 .8 .8 .8 .8 .8 .8 .8 .8 ; .8 0.6 0.6 0.6 1 1 1 0.6 0.6 0.6;.8 0.6 0.6 0.6 1 1 1 0.6 0.6 0.6; .8 0.6 0.6 0.6 1 1 1 0.6 0.6 0.6;.8 1 1 1 0.6 0.6 0.6 1 1 1;.8 1 1 1 0.6 0.6 0.6 1 1 1;.8 1 1 1 0.6 0.6 0.6 1 1 1;.8 0.6 0.6 0.6 1 1 1 0.6 0.6 0.6;.8 0.6 0.6 0.6 1 1 1 0.6 0.6 0.6;.8 0.6 0.6 0.6 1 1 1 0.6 0.6 0.6];
% Create matrix to show white/gray checkers
figure('position', [500 200 700,500]) % create new figure with specified size
grid on
imshow(checker); % Show image
colormap gray; % Make values gray
set(gca,'Position',[0 0 1 1]); % Adjust position
...
}

回答(1 个)

Chris Portal
Chris Portal 2016-4-17
The grid spacing is driven by the tick spacing in your axes, so it requires your setting the XTick and YTick properties. For example:
figure
plot(1:100)
grid on
set(gca,'xtick',[0:5:100])
set(gca,'ytick',linspace(0,100,13))

类别

Help CenterFile Exchange 中查找有关 Sudoku 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by