You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
How to print Value in next line of Table in App desiginer
3 views (last 30 days)
Show older comments
Med Future
on 26 Dec 2022
Hello, I hope you are doing well. I have used the sprintf as follow But it does not go to the next file all character are in single row/line when I print it on Table in app designer
pred11= sprintf('\n Class 1 Butterfly Levels: %d\n\n\n Class 1 Butterfly DValue: [%s]\nMaximum Value of Butterfly:%d\nMinimum Value Butterfly :%d\n',...
T.Levels, join(string(unique(T.DValue)),' '), T.Dmaximum, T.Dminimum);
Accepted Answer
VBBV
on 26 Dec 2022
use [ ] operator as below or try with for loop which always works as intended
pred11= sprintf('\n Class 1 Butterfly Levels: %d\n\n\n Class 1 Butterfly DValue: [%s]\nMaximum Value of Butterfly:%d\nMinimum Value Butterfly :%d\n',...
[T.Levels; join(string(unique(T.DValue)),' '); T.Dmaximum; T.Dminimum]);
22 Comments
VBBV
on 26 Dec 2022
Edited: VBBV
on 26 Dec 2022
try othwerwise with for loop
for k = 1:length(T.Levels)
% remaining code...
pred11= sprintf('\n Class 1 Butterfly Levels: %d\n\n\n Class 1 Butterfly DValue: [%s]\nMaximum Value of Butterfly:%d\nMinimum Value Butterfly :%d\n',...
T.Levels(k), join(string(unique(T.DValue(k))),' '), T.Dmaximum(k), T.Dminimum(k));
end
Med Future
on 26 Dec 2022
@VBBV Error using vertcat
Dimensions of arrays being concatenated are not consistent.
Med Future
on 26 Dec 2022
VBBV
on 26 Dec 2022
Edited: VBBV
on 26 Dec 2022
if i run using data provided, it works fine, but your problem is something different i guess, its printing the data into a table in App designer. you may not need sprintf function, instead you can directly call the table variables using structure to print or display them in a table in App designer
load('print.mat')
for k = 1:length(T.Levels)
pred11= sprintf('\nClass 1 Butterfly Levels: %d\n\n\nClass 1 Butterfly DValue: [%s]\nMaximum Value of Butterfly:%d\nMinimum Value Butterfly :%d\n',...
T.Levels(k), join(string(unique(T.DValue(k))),' '), T.Dmaximum(k), T.Dminimum(k))
end
pred11 =
'
Class 1 Butterfly Levels: 6
Class 1 Butterfly DValue: [80]
Maximum Value of Butterfly:650
Minimum Value Butterfly :80
'
VBBV
on 26 Dec 2022
Edited: VBBV
on 26 Dec 2022
After testing in Matlab online, please make these changes, the below code works fine
load('print.mat')
vars = {'Levels','Dvalue','Dmaximum','Dminimum'};
T = table(T.Levels,unique(T.DValue),T.Dmaximum,T.Dminimum,'VariableNames',vars)
fig = uifigure
uit = uitable(fig,'Data',T)
Med Future
on 26 Dec 2022
@VBBV Not working, it just gives all values in array. No the print which i want
VBBV
on 26 Dec 2022
Edited: VBBV
on 26 Dec 2022
add one extra line shown in code below , hope this works
load('print.mat')
vars = {'Levels','Dvalue','Dmaximum','Dminimum'};
T = table(T.Levels,unique(T.DValue),T.Dmaximum,T.Dminimum,'VariableNames',vars)
T = rows2vars(splitvars(T)) % add this line
T = table(T.OriginalVariableNames,T.Var1,'VariableNames',{'Parameter','Value'}) % add this too
fig = uifigure
uit = uitable(fig,'Data',T)
VBBV
on 27 Dec 2022
you can change the vars in my previous code as
vars = {'Class 1 Butterfly Levels','Class 1 Butterfly Dvalue','Maximum value of Butterfly','Minimum value of Butterfly'};
and after modification it will be
load('print.mat')
% this change below
vars = {'Class 1 Butterfly Levels','Class 1 Butterfly Dvalue','Maximum value of Butterfly','Minimum value of Butterfly'};
T = table(T.Levels,unique(T.DValue),T.Dmaximum,T.Dminimum,'VariableNames',vars)
T = rows2vars(splitvars(T)) % add this line
T = table(T.OriginalVariableNames,T.Var1,'VariableNames',{'Parameter','Value'}) % add this too
fig = uifigure
uit = uitable(fig,'Data',T)
Med Future
on 27 Dec 2022
@VBBV We can print the data into multiple rows
like in this the data should be in four rows.
One for Levels
2nd for Dvalue
3rd for Dmaximum
4th for Dminimum
Adam Danz
on 27 Dec 2022
@Med Future, I cannot understand what the goal is. Please provide an illustration of what you'd like to accomplish.
Med Future
on 28 Dec 2022
@Adam Danz As you see above my code i printing the character on same line while i am applying \n in my code
I want to print the character in new line for example
We can print the data into multiple lines
like in this the data should be in four lines.
One for Levels
2nd for Dvalue
3rd for Dmaximum
4th for Dminimum
Adam Danz
on 28 Dec 2022
Where should these text appear? In the command window? In a table? A uitable? The goal is still unclear.
I see that VBBV has given you lots of solutions and that you reply with phrases like "not working", "so many rows". This is a sign that the volunteers are not clear what your goal is or that you are unsure of the goal.
Rather than us guessing at what you want, developing a solution for that guess, and then finding out that it's not exactly what you're looking for, please illustrate exactly what you want.
I'd be happy to provide one more solution if the goal is crystal clear.
Med Future
on 29 Dec 2022
Edited: Adam Danz
on 29 Dec 2022
Okay Let me explain this to you I want to print value in appdesigner Table.
I have the Table in print.mat file in which different field exist. I have write the following code, which gives character array. which is basically in single line
pred11= sprintf('\n Class 1 Butterfly Levels: %d\n\n\n Class 1 Butterfly DValue: [%s]\nMaximum Value of Butterfly:%d\nMinimum Value Butterfly :%d\n',...
T.Levels, join(string(unique(T.DValue)),' '), T.Dmaximum, T.Dminimum);
I want to print in multiple line in appdesigner table for example like the following
Class 1 Butterfly Levels: 6
Class 1 Butterfly DValue: [80 85 355 550 600 650]
Maximum Value of Butterfly:650
Minimum Value Butterfly :80
VBBV
on 29 Dec 2022
See snapshot below , if this is what you want
load('print.mat')
% this change below
vars = {'Class 1 Butterfly Levels','Class 1 Butterfly Dvalue','Maximum value of Butterfly','Minimum value of Butterfly'};
S = num2str(unique(T.DValue)) % convert the Dvalue to character
D = {vars{1},T.Levels;vars{2},S;vars{3},T.Dmaximum;vars{4},T.Dminimum};
fig = uifigure;
uit= uitable(fig);
uit.Data = D;
uit.Position = [71 61 500 233]; % modify the table size using its position property
More Answers (0)
See Also
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)