Azzera filtri
Azzera filtri

Plotting graph from table using app designer

17 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Mohammad Sami
Mohammad Sami il 22 Lug 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

Più risposte (0)

Categorie

Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by