필터 지우기
필터 지우기

How to add variable to Table in MatLab App Designer ?

조회 수: 28 (최근 30일)
meryem berrada
meryem berrada 2021년 11월 26일
답변: meryem berrada 2021년 11월 29일
Hello,
I have a few variables that I would like to add into columns of a Table in MatLab App designer.
Ma variables are: app.A, app.B, app.C
I set the Table (called app.Table) to have 3 columns from the design view, but I can't figure out how to add my variables to it.
This is what I have to far:
app.Table{1}=(app.A); %gives me error 'Unable to perform assignment because brace indexing is not supported for variables of this type.'
app.Table{2}=(app.B);
app.Table{3}=(app.C);
Can anyone help please ?
  댓글 수: 2
HWIK
HWIK 2021년 11월 26일
Have you tried row and column indexing?
meryem berrada
meryem berrada 2021년 11월 26일
I am not sure how ? The variables A, B and C are all 1x50. Please elaborate if possible.

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

채택된 답변

meryem berrada
meryem berrada 2021년 11월 29일
Thank you everyone for your help. This is how I solved my problem:
properties (Access = public)
t;
A;
B;
C;
% Button pushed function: RunButton
function RunButtonPushed(app, event)
%generate table
app.t = [A' B' C']; %create matrix of table data
app.Table.Data = app.t; % Add data to the Table UI Component
end
% Cell edit callback: Table
function TableCellEdit(app, event)
app.Table=app.table(A,B,C,'VariableNames',{'A' 'B' 'C'});
end

추가 답변 (1개)

Peter Perkins
Peter Perkins 2021년 11월 26일
There are probably a couple things wrong with
app.Table{1}=(app.A)
First, if app.Table doesn't yet exist, you are not creating a table. Second, even if app.Table exists, you need to use two subscripts on a table.
I imagine you want something like
app.Table = table(app.A,app.B,app.C,'VariableNames',{'A' 'B' 'C'});
  댓글 수: 2
meryem berrada
meryem berrada 2021년 11월 26일
Hi,
Thank you for responding. I have defined this for the table:
% Cell edit callback: Table
function TableCellEdit(app, event)
app.Table=app.table(app.A,app.B,app.C,'VariableNames',{'A' 'B' 'C'});
end
But nothing gets added to the table.
Peter Perkins
Peter Perkins 2021년 11월 28일
I don't know what app.table is. Do you mean
app.Table=table(app.A,app.B,app.C,'VariableNames',{'A' 'B' 'C'});
I don't know much about App Designer, so I could be wrong.

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

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by