I have figured out how to edit the uitable but i am trying to figure out how can i save the input vales, i added another add button to save the program but it is not working out and how can i plot the x and y values from the table using a scatter graph ?
properties (Access = private)
sensor_table = gobjects(1,1); %initialize as graphics object
sensor_values
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: RunButton
function RunButtonPushed(app, event)
platewidth=app.WidthEditField.Value;
plateheight=app.HeightEditField.Value;
GridWidth = app.GridWidthEditField.Value;
GridHeight = app.GridHeightEditField.Value;
Xcoordinate = app.XcoordinateEditField.Value;
Ycoordinate = app.YcoordinateEditField.Value;
Lengthofcell = app.LengthofcellEditField.Value;
Gridx = Xcoordinate : Lengthofcell : GridWidth+Xcoordinate;
Gridy = Ycoordinate : Lengthofcell : GridHeight+Ycoordinate;
if Gridx(end) >= platewidth
error('Grid x (%d) + grid width (%d) >= plate width (%d)', Xcoordinate, GridWidth, platewidth);
end
if Gridy(end) >= plateheight
error('Grid y (%d) + grid height (%d) >= plate height (%d)', Ycoordinate, GridHeight, plateheight);
end
Mx = length(Gridx);
My = length(Gridy);
[x, y] = meshgrid(Gridx, Gridy);
%create the list of text
labels = string(1:Mx*My).';
%insert the labels
hold(app.UIAxes, 'on')
scatter(app.UIAxes, x, y, "O", "MarkerFaceColor", 'r')
text(app.UIAxes, x(:), y(:), labels, 'HorizontalAlignment', 'left', 'verticalalignment', 'bottom')
%calculte the grid lines
grid1x = [Gridx;Gridx];
grid1y = [Gridy(1); Gridy(end)];
grid2x = [Gridx(1); Gridx(end)];
grid2y = [Gridy; Gridy].';
plot(app.UIAxes, grid1x, grid1y, "Color", 'b');
plot(app.UIAxes, grid2x, grid2y, "Color", 'b');
rectangle(app.UIAxes, 'Position', [0 0 platewidth plateheight],'LineWidth', 5);
box(app.UIAxes, 'on')
grid(app.UIAxes, 'on')
xlim(app.UIAxes,[0 platewidth])
ylim(app.UIAxes,[0 plateheight])
xticks(0:Xcoordinate:platewidth)
yticks(0:Ycoordinate:plateheight)
hold(app.UIAxes, 'off')
N = app.NoofSensorsEditField.Value;
sensor_number = (1:N).';
X_coordinate = zeros(N,1);
Y_coordinate = zeros(N,1);
T = table(sensor_number, X_coordinate, Y_coordinate);
app.sensor_table = uitable(app.UIFigure, 'Data', T);
app.sensor_table.ColumnEditable = true;
end
% Button pushed function: AddButton
function AddButtonPushed(app, event)
app.sensor_values=uitable(app.UIFigure, 'Data', T);