How to plot a scatter plot from a UI table
Show older comments
I have edited and added values to a UI Table based on the Number of sensors needed . I am Trying to find a method to plot the new values in a scatter plot
properties (Access = private)
sensor_table = gobjects(1,1); %initialize as graphics object
T% Table to be shared between callbacks
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: RunButton
function RunButtonPushed(app, event)
N = app.NoofSensorsEditField.Value;
sensor_number = (1:N).';
x_coordinate = zeros(N,1);
y_coordinate = zeros(N,1);
app.T = table(sensor_number, x_coordinate, y_coordinate);
app.sensor_table = uitable(app.UIFigure, 'Data', app.T);
app.sensor_table.ColumnEditable = true;
end
% Button pushed function: ADDButton
function ADDButtonPushed(app, event)
app.T=app.sensor_table;

Answers (1)
Ananya Tewari
on 2 Aug 2021
Hi,
I understand you want to plot the table data using the scatter plot. We can leverage the scatter plot doc, here is an example for the same. We can give the UIAxes on which data is to be plotted, alongwith the data coordinates.
scatter(app.UIAxes,sensor_number,[x_coordinates;y_coordinates]);
Feel free to change the input arguments as per your requirement.
9 Comments
Jeet Shetty
on 2 Aug 2021
Ananya Tewari
on 3 Aug 2021
Currently sensor_number is not defined and that is the probable cause for the error. You can define sensor_number as a property in the Code and access it inside the callbacks. Please refer to this link for creating properties in App Designer code.
Hope this helps !
Jeet Shetty
on 3 Aug 2021
Ananya Tewari
on 3 Aug 2021
You can directly use the sensor_number as app.T.sensor_number, if T is accessible and it contains sensor_number as a column.
Jeet Shetty
on 3 Aug 2021
Jeet Shetty
on 3 Aug 2021
Jeet Shetty
on 4 Aug 2021
Walter Roberson
on 4 Aug 2021
You have to pass save() a list of character vectors or string scalars, each one representing a variable name to save or an option. The names cannot be qualified in any way. For example,
save('myfile.mat', 'app.UIFigure.Data') %WRONG
uif_data = app.UIFigure.Data; save('Myfile.mat', 'uif_data'); %OK
Jeet Shetty
on 4 Aug 2021
Categories
Find more on Creating, Deleting, and Querying Graphics Objects 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!