How to create an auto generated number?

here I would like to create an auto generated number that when I chose the image of the browse button, then the image will appear in the axes, along with that then an auto number will automatically appear in an edit text. For example for the first time, then the ID to be shown is 001, then I'll save that data to the MySQL database. Furthermore, when I choose a new image, which will show the ID is 002, That is so, how so I can make it that way?

 採用された回答

Sean de Wolski
Sean de Wolski 2016 年 6 月 1 日

0 投票

ii = 3
strii = num2str(ii,'%03i')

4 件のコメント

Alvindra Pratama
Alvindra Pratama 2016 年 6 月 2 日
i have tried your code, but the ID always shown 003 and never change. I want after ID display 001, the next ID is 002, The next is 003, and continue like this. How can i make like this?
Stephen23
Stephen23 2016 年 6 月 2 日
for k = 1:3
out = num2str(k,'%03i')
end
And you can learn about for-loops in the introductory tutorials:
Alvindra Pratama
Alvindra Pratama 2016 年 6 月 2 日
i think we got miss comunication here. I have a GUI like this :
I want to make automatic number every time I select a photo from the browse button, where each number that will continue to sequence. For example for the first data I stored to MySQL database, has ID 1, for the second data I stored to then have a MySQL database ID 2, and so on, each number will be increased so that no duplicate numbers.
Stephen23
Stephen23 2016 年 6 月 3 日
編集済み: Stephen23 2016 年 6 月 3 日
@Alvindra Pratama: then you will need to initialize and store a counter scalar, and increment it by one each time you generate a new ID. Possibly the best place to store the counter would be via guidata.

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

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by