フィルターのクリア

How to input a specific data into Matlab Gui uitable via clicking a button?

1 回表示 (過去 30 日間)
Runo Insan
Runo Insan 2020 年 3 月 12 日
コメント済み: Runo Insan 2020 年 3 月 14 日
Hi,
In Matlab gui, I have a table and a clickable button. I want to input random numbers which has spesific limits defined before to put as table's first column. For example:
function pushbutton1_Callback(hObject, eventdata, handles)
values1 = randi([-90 -10], 5, 1);
values1 = randi([0 10], 5, 2);
set(handles.uitable1, 'Data', num2cell(values1));
end
This code generates numbers into a table, but only the last code's limits are used. I can't generate negative numbers.
I expected this matrix:
-90 0
-80 8
-65 5
-10 2
-11 10
But the result is:
0 4
4 9
5 3
6 10
10 3
The first column's limits are changing, and I couldn't solve it to hold its own limits as defined before.
Hence, I will use a button click to generate numbers in a column of Matlab Gui's table to insert column based random but has min-max limited numbers.
Thanks.

採用された回答

Mohammad Sami
Mohammad Sami 2020 年 3 月 13 日
The reason is because your second line of code overwrites your previous assignment.
You need to specify the column in your code.
function pushbutton1_Callback(hObject, eventdata, handles)
values1(:,1) = randi([-90 -10], 5, 1);
values1(:,2) = randi([0 10], 5, 1);
set(handles.uitable1, 'Data', num2cell(values1));
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

製品


リリース

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by