How to plot the selected column on app.UItable .

4 Ansichten (letzte 30 Tage)
Akshay
Akshay am 22 Apr. 2024
Bearbeitet: akshatsood am 22 Apr. 2024
Hi all,
I am working on developing an application in matalb. The Run botton will import the excel file and display the columns in the table. I want to program the plot botton in such a way that once the columns are selected in the app.UItable and plot botton clicked by the user. A plot is generated in the app.UIaxes.
I am getting difficulty in coding the second portion where I want to select the column and plot them.
Any help will be greatly appreciated.
Thank you

Antworten (1)

akshatsood
akshatsood am 22 Apr. 2024
Bearbeitet: akshatsood am 22 Apr. 2024
I understand that you want to plot data from the column selected in your app. To achieve the functionality you are describing, I will provide a general outline and example code for how to implement the "plot" button functionality within the App Designer, as it's the more user-friendly and recommended method for developing MATLAB apps.
For the "Plot" button, you need to write a callback function that does the following:
1. Get Selected Data: retrieve the selected columns from "app.UITable".
2. Plot Selected Data: plot the selected data on "app.UIAxes".
Here is an example of how the callback function for the "plot" button might look:
% Callback function for the Plot button
function PlotButtonPushed(app, event)
% Get the indices of the selected columns
selectedColumns = app.UITable.Selection;
% Extract the selected Columns Data
dataToPlot = app.UITable.Data(:, selectedColumns(2:end)); % ignoring row headers
% Plot the Data
plot(app.UIAxes, dataToPlot);
xlabel(app.UIAxes, 'X-axis Label');
ylabel(app.UIAxes, 'Y-axis Label');
end
This example should give you a good starting point. You will need to tailor the code to fit the specifics of your app, such as how data is stored and managed within your UITable and any specific plotting requirements. Should you encounter any difficulties or have any follow up question, please let me know in the comments. Additionally, do share you app file.
I hope this helps.

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by