Piloting graph in app designer

조회 수: 23 (최근 30일)
Bilal Larouzi
Bilal Larouzi 2020년 6월 14일
댓글: Bilal Larouzi 2020년 6월 16일
Hello friends.
I am trying to create an app in Matlab app designer to plot data from tables.
I want the app to sum the second and third columns then plot the sum of these columns various the first column in the table.
i am facing proplem "Unrecognized method, property, or field 'Var1' for class 'matlab.ui.control.Table'" when i am trying to plot variables i hope you could help me with this problem.

채택된 답변

Cris LaPierre
Cris LaPierre 2020년 6월 15일
편집: Cris LaPierre 2020년 6월 15일
Ok, app.BS is a uitable. app.BS.Data is the information displayed in that uitable.
What I would do, then, is create a property in the app to hold the raw data loaded from BS.txt.
properties (Access = private)
data % raw data from text file
end
I would add a new variable summing Var2 and Var3 to it (I called it app.data). Then I would plot Var1 vs this new variable.
% Button pushed function: ChooseButton
function ChooseButtonPushed(app, event)
[filename, pathname] = uigetfile({'*.txt'}, 'File Selector');
app.data = readtable (fullfile(pathname, filename), 'HeaderLines', 0);
app.BS.Data = app.data;
app.BSEditField.Value = filename;
end
% Button pushed function: DisplayButton
function DisplayButtonPushed(app, event)
app.data.sumVars = app.data.Var2+app.data.Var3;
plot(app.UIAxes, app.BS.Data.Var1,app.data.sumVars)
end

추가 답변 (1개)

Cris LaPierre
Cris LaPierre 2020년 6월 15일
편집: Cris LaPierre 2020년 6월 15일
I suspect the variables app.BS.Var1 and app.BS.Var2 don't exist. Perhaps the variable app.BS.Data.Var1 does?
Still, there is an easier way to do this.
  1. Create a new table variable that is the sum of columns 2 and 3
  2. Plot column one vs the new column
app.BS.Data.sumVars = app.BS.Data(:,2)+app.BS.Data(:,3);
plot(app.UIAxes,app.BS.Data(:,1),app.BS.Data.sumVars)
  댓글 수: 3
Cris LaPierre
Cris LaPierre 2020년 6월 15일
편집: Cris LaPierre 2020년 6월 15일
Try updating it to
app.BS.Data.sumVars = app.BS.Data.(2)+app.BS.Data.(3);
plot(app.UIAxes,app.BS.Data(:,1),app.BS.Data.sumVars)
If that doesn't work, please save your variable BS to a mat file and attach it to your post.
Bilal Larouzi
Bilal Larouzi 2020년 6월 15일
i have attached app and the BS file

댓글을 달려면 로그인하십시오.

카테고리

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