Effacer les filtres
Effacer les filtres

Plotting graph from table using app designer

17 vues (au cours des 30 derniers jours)
Chinedu Okoye
Chinedu Okoye le 21 Juil 2020
I have created an app that will prompt the user to select a .txt file to read into a table, and the table is made up of seperate columns. I want to use the first column to be populate the X axis and the rest of the columns to populate the y axis in different individual lines. To clarify, if there are 4 columms there should be 3 lines with the second through fourth columns being the data that make up the points on Y axis for each line. What is the best way to go about doing this in matlab app designer?

Réponse acceptée

Mohammad Sami
Mohammad Sami le 22 Juil 2020
First in your app in the design view, you will need to add an UIAxes to the app.
Thereafter you can plot on it. Add a callback to the plot button. And inside you can prompt the user to select the file.
Then you can load and plot it.
function plotButtonPushedCallback(app,event)
[filename,folder] = uigetfile('*.txt');
file = fullpath(folder,filename);
tab = readtable(file); % assuming default options work.
X = tab.(1);
Y = table2array(tab(:,2:end));
plot(app.UIAxes,X,Y);
end

Plus de réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by