필터 지우기
필터 지우기

For loop iterations to display in uitable rows

조회 수: 3 (최근 30일)
Banjo
Banjo 2018년 1월 7일
댓글: Banjo 2018년 1월 7일
Hello, how could I display all iterations of a for loop into uitable rows? I have created uitable in GUI and I put
set(handles.uitable1,'data',i)
into for loop and I only get those iterations displayed in the first row.
Thank you!

채택된 답변

SRT HellKitty
SRT HellKitty 2018년 1월 7일
I'm not very clear on the question, but I assume you are saying you would like to create a list of numbers the 'i' variable has in it from running the for loop?
My solution to that would be to create a matrix(or cell array) where it loads the iteration. Something like this
iterations = 10; % we want 10 iterations in this for loop
i_Array = zeros(1,iterations); %create an zero array with the amount of iterations
for i = 1:iterations
i_Array(i) = i; % for iteration 1, set i_Array(1) to 1.
% do something else in the loop
end
set(handles.uitable1,'data',i_Array)
  댓글 수: 1
Banjo
Banjo 2018년 1월 7일
Thank you. Since I wanted data to be displayed in a rows instead of columns I just added (:) to i_Array.
set(handles.uitable1,'data',i_Array(:))

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by