Add multi-row data to App Designer Text Area
Show older comments
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 Comments
dpb
on 15 Oct 2023
Looks a lot more appropriate place to use a table than a text object--it will be a pain to encode/decode as you're finding out just thinking about it...show us what you think you want the display to look like and how does the value "1" of "D" relate to the array T?
John Sal
on 15 Oct 2023
dpb
on 15 Oct 2023
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
on 15 Oct 2023
Answers (2)
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.
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 Comments
Asi
on 16 Oct 2023
Due to curiosity, I was running the code below which I changed the table content:
clc;
clear all;
close all;
T1 = table([3;2;7;6], [9;4;5;0]);
T1 = join(string(reshape(1:numel(T1),[],2))," ")
T2= "D=1";
T3="SALE=";
fig = uifigure;
txa = uitextarea(fig);
txa.Value = ([T1; T2; T3]);
and I got the following output in the UI:
1 5
2 6
3 7
4 8
What did I do wrong in the reshape?
T1 = table([3;2;7;6], [9;4;5;0]);
T1 = join(string(reshape(1:numel(T1),[],2))," ");
T1 = table([3;2;7;6], [9;4;5;0]);
1:numel(T1)
That's because the original post by the OP said 1:6 was the actual data wanted and there's no sense in creating a table just to turn immediately turn it into an array so I just created the array inside as the argument in reshape. So just copying that particular piece of code replaced the table T1 with an array of the sequence of the number of elements that were in the table (8).
dpb
on 16 Oct 2023
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.
Categories
Find more on Data Type Identification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!