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

7 ビュー (過去 30 日間)
Kayla Kloster 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 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 Center および File ExchangeSudoku についてさらに検索

### Community Treasure Hunt

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

Start Hunting!

Translated by