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

조회 수: 4 (최근 30일)
Kayla Kloster
Kayla Kloster 2016년 4월 17일
답변: Chris Portal 2016년 4월 17일
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