Borrar filtros
Borrar filtros

Plotting graph from table using app designer

17 visualizaciones (últimos 30 días)
Chinedu Okoye
Chinedu Okoye el 21 de Jul. de 2020
Respondida: Mohammad Sami el 22 de Jul. de 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?

Respuesta aceptada

Mohammad Sami
Mohammad Sami el 22 de Jul. de 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

Más respuestas (0)

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by