Add multi-row data to App Designer Text Area

8 ビュー (過去 30 日間)
John Sal
John Sal 2023 年 10 月 15 日
コメント済み: dpb 2023 年 10 月 16 日
Hi,
I wish to add multi-row data to App Designer Text Area. As the data to be shown is comprised from different types (a, d and sale), how can I merge them into one data type (which?) and to populate the Text area?
Thanks a lot.
Code:
T = table([1;2;3], [4;5;6])
a = table2array(T)
d="D=1"
sale="SALE="
  4 件のコメント
dpb
dpb 2023 年 10 月 15 日
I'm more confused than ever by that...what are you/the user going to do with this in this format?
Knowing this must be minimal data for posting a question, what's the real data look like?
You can convert everything to text and make it look like that in a text control, but it will be painful to do anything with, particularly if the user is allowed to make changes and then you have to try to parse the new data.
John Sal
John Sal 2023 年 10 月 15 日
I do not know how to populate muiltilines in the Text area but furthermore how can I do it with mixed data types (table and several strings). Based on your first comment I thought that converting everything into table will ease.
This is the real data I wish to add is:
T = table([1;2;3], [4;5;6])
d="D=1"
sale="SALE="
The output in the text area should be like this:
1 4
2 5
3 6
D=1
SALE=
Thanks

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

回答 (2 件)

dpb
dpb 2023 年 10 月 15 日
移動済み: dpb 2023 年 10 月 15 日
You can do it by putting every record into a new line in a string array, but it will be a pain to deal with.
T=join(string(reshape(1:6,[],2))," ");
d="D=1";
sale="SALE=";
app.textarea.Value=[T;d;sale];
but it still seems most bizarre way to present the data to the user--but, granted, we don't know the whole story.

Ali razi
Ali razi 2023 年 10 月 15 日
編集済み: dpb 2023 年 10 月 15 日
Hi,
Not an elegent way but I hope it works for you
T1 = table([1;2;3], [4;5;6])
T1 = table2array(T1);
T1 = num2str(T1)
T2= "D=1";
T3="SALE=";
app.yourTextArea.Value = ([T1; T2; T3]);
  4 件のコメント
Asi
Asi 2023 年 10 月 16 日
編集済み: Asi 2023 年 10 月 16 日
Thanks dpb for the tip. I presume you mean: T1 = join(string(reshape(table2array(T1),[],2))," ")
dpb
dpb 2023 年 10 月 16 日
Well, not really. What I'm driving at is that there's no point in creating a table if all one is going to do with it is turn it into an array; create the array only in the first place; then there's no need for table2array.

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

カテゴリ

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

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by