How to represent each grid numerically?

조회 수: 5 (최근 30일)
Richa Sarmah
Richa Sarmah 2019년 11월 8일
편집: Adam Danz 2019년 11월 13일
I have made square grids in the entire MATLAB workspace having 0.5 spacing. How can i represent those grids in number? Counting must start from 1 and in increasing order from bottom left to right and then go to upper line respectively
  댓글 수: 2
KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 11월 8일
Can you more specific please?
Are you looking for insert number inside the grid elements?
Richa Sarmah
Richa Sarmah 2019년 11월 8일
I don"t want to display numbers inside the grid, instead a serially increasing number is to be assigned to each grid and that number is to be stored in veriable or matrix form.

댓글을 달려면 로그인하십시오.

답변 (1개)

Adam Danz
Adam Danz 2019년 11월 8일
편집: Adam Danz 2019년 11월 13일
% Inputs
xrng = [0,9]; % [left, right] bound of x axis
yrng = [0,8]; % [lower, upper] bound of y axis
gridInt = 0.5; % grid spacing
% Compute the rest
nBlocks = floor([diff(xrng), diff(yrng)] ./ gridInt); % number of complete grid squares for [x,y] axes
gridNumbers = flipud(reshape(1:prod(nBlocks), nBlocks)');
gridNumbers is a matrix of grid block counts starting at the bottom, left corner and increasing rightward then upward.

Community Treasure Hunt

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

Start Hunting!

Translated by