How to display cell format or table format in GUI table?

조회 수: 2 (최근 30일)
Siti Khadijah Norzafri
Siti Khadijah Norzafri 2020년 3월 19일
댓글: Siti Khadijah Norzafri 2020년 3월 21일
Hi Im really in need of help on how to display cell format or table format in GUI table. And I tried using uitable it worked but it does'nt update the data. So I now i just want to know how to display it on the GUI table.
Begining=5000;
YI=0.1; %Yearly Interest
Payment=1000; %Monthly Payment
Data=zeros(1,5); %Data result array
x=1; % x and y are counters
y=1;
while Begining>Payment && Begining>0
%Non Calculated Data
Data(y,x)=Begining; %Saving to Array
x=x+1; %Adding Column Index
Data(y,x)=Payment;
x=x+1;
%Calculations
MI=(Begining*YI)/12; %Monthly Interest
Data(y,x)=MI;
x=x+1;
Principal=Payment-MI; %Principal Payment
Data(y,x)=Principal;
x=x+1;
Ending=Begining-Principal; %Ending Balance
Data(y,x)=Ending;
x=1; %Resetting Column Index
if Payment<=MI
break;
end
Begining=Ending; %Setting New Begining Balance
y=y+1; %Adding Row Index
end
if Payment<=MI
fprintf('Invalid Data, Insuficient Payment');
else
%Final Iteration
Begining=Ending;
Data(y,x)=Begining;
x=x+1;
Data(y,x)=Payment;
x=x+1;
MI=0;
Data(y,x)=MI;
x=x+1;
Principal=Payment;
Data(y,x)=Principal;
x=x+1;
Ending=0;
Data(y,x)=Ending;
x=1;
Data2=num2cell(Data); %Converting into cell
%Converting into Table
Data3=cell2table(Data2,'VariableNames',{'Begining Balance','Payment','Interest','Principal','Ending Balance'});
end

채택된 답변

Robert U
Robert U 2020년 3월 19일
Hi Siti Khadijah Norzafri,
apparently uitable() accepts table data:
fh = uifigure;
th = uitable(fh,'Data',Data3);
You can use the property 'Position' to adjust size and position of the table within the figure.
th.Position = th.Position + [0 140 150 -140];
Kind regards,
Robert

추가 답변 (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