필터 지우기
필터 지우기

Plotting graph from table using app designer

조회 수: 17 (최근 30일)
Chinedu Okoye
Chinedu Okoye 2020년 7월 21일
답변: Mohammad Sami 2020년 7월 22일
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?

채택된 답변

Mohammad Sami
Mohammad Sami 2020년 7월 22일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by