How to create an array from a GUI where the array length changes by user's input?

2 ビュー (過去 30 日間)
Giuseppe Marino
Giuseppe Marino 2021 年 5 月 10 日
編集済み: Giuseppe Marino 2021 年 5 月 10 日
Hi everyone,
I was trying to make a simple GUI, I hope. The path that i wish to implement is the following one:
1: the user chooses the length of the array.
2: In the GUI, the users has to be able to insert all the variables oneshot, from 1 to array-length.
3: i need to save the array.
I hope i was clear. Thank you for the help.

採用された回答

Jan
Jan 2021 年 5 月 10 日
編集済み: Jan 2021 年 5 月 10 日
The easiest way is to omit step 1, but to let the use create as many values as wanted and count them afterwards. There is a nice GUI for this job already: The editor. So what about opening it and typing:
data = [1, 3, 2, 4]
Then saving is easy also. Which format do you want?
Sorry for this trivial approach, why why reinventing the wheel?
  1 件のコメント
Giuseppe Marino
Giuseppe Marino 2021 年 5 月 10 日
編集済み: Giuseppe Marino 2021 年 5 月 10 日
I have tried your method and it works for my scope. But i was wondering a different way.
I was trying to use a GUI like that:
prompt={'How many plies are?'};
title='Plies number';
answer=inputdlg(prompt,title,[1 10]);
N_ply=str2double(answer{1});
and after this part, i want to create a similar GUI where the user are able to insert one shot all the array-values. If the N_ply=10, I want to show another GUI where there are ten different place where the user could insert all the values. The ten values has to be stored. So the length of answer for the second GUI could change..
Hope I have been more clear now.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by