Change the numer rows of a uitable in MATLAB gui automatically using GUIDE?

4 ビュー (過去 30 日間)
Nikhil Tamhankar
Nikhil Tamhankar 2017 年 11 月 19 日
How to create an option (text box) to enter a number to automatically change the number rows of a uitable in MATLAB gui using GUIDE?

回答 (2 件)

Walter Roberson
Walter Roberson 2017 年 11 月 19 日
編集済み: Walter Roberson 2017 年 11 月 20 日
uit = uitable('Data', [0 0 0]);
FirstN = @(Matrix, N) Matrix(1:N, :);
ChopN = @(Matrix, N) FirstN([Matrix; zeros(N, size(Matrix,2))], N);
uicontrol('style', 'edit', 'Callback', @(src, event) set(uit, 'data', ChopN(get(uit, 'data'), str2double(get(src, 'string'))));
  10 件のコメント
Walter Roberson
Walter Roberson 2018 年 7 月 10 日
You programmed a cell edit callback, which is a callback that activates when the user edits data in the uitable. If you want the change to happen when the user edits the edit box, then
function edit3_Callback(hObject, eventdata, handles)
FirstN = @(Matrix, N) Matrix(1:N, :);
ChopN = @(Matrix, N) FirstN([Matrix; zeros(N, size(Matrix,2))], N);
set(handles.uitable1, 'Data', ChopN(get(handles.uitable1, 'Data'), str2double(get( hObject, 'string'))) )
Vinayak Appasaheb Bhatte
Vinayak Appasaheb Bhatte 2018 年 7 月 10 日
Thanks a lot @Walter for your kind explanation, I did work finally.

サインインしてコメントする。


Image Analyst
Image Analyst 2017 年 11 月 20 日
You can just assign the data to it and it will automatically adjust its size to handle/display all the rows and columns in your data matrix:
handles.uitable1.Data = yourData;
Or, you can just click on the little icon in the Columns entry in the Property Inspector, which you can bring up in GUIDE by double clicking on the table control.
  3 件のコメント
Image Analyst
Image Analyst 2017 年 11 月 21 日
Basically get the string from the edit box
contentsString = handles.edit1.String;
Then parse contentsString to get what you want and expect - a row or whole matrix of whatever - and load that into yourData and then use the code I originally gave you:
handles.uitable1.Data = yourData;
Nikhil Tamhankar
Nikhil Tamhankar 2017 年 11 月 25 日
Thank you sir. Will try to understand your suggestion and try to implement it.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeApp Building についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by