How can i align these numbers to each cell

1 view (last 30 days)
hey guys , i have tried to number each cell in my grid but i am struggling with the alignment. It wouldbe great if someone could help or give any on how to label the nodes . I am running it on GUI
%generate where each text will go
%create the list of text
string = mat2cell(num2str((1:M*M)'),ones(M*M,1));
%insert the labels
hold (app.UIAxes, 'on')
%calculte the grid lines
grid = app.XcoordinateEditField.Value:app.LengthofcellEditField.Value:app.GridWidthEditField.Value;
grid1 = [grid;grid];
grid2 = repmat([app.XcoordinateEditField.Value;app.GridWidthEditField.Value],1,length(grid));
%plot the grid lines
hold (app.UIAxes, 'on')
hold (app.UIAxes, 'on')

Accepted Answer

Walter Roberson
Walter Roberson on 25 Jun 2021
Your X and Y creation are wrong. You need to multiply the 1:M by the width of the cell (and possibly add an offset, especially if you want to center the number in the cell)
Jeet Shetty
Jeet Shetty on 9 Jul 2021
Oh cool cool , thanks. i trying to edit that ui table at the moment 😁

Sign in to comment.

More Answers (0)


Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by