How to print Value in next line of Table in App desiginer
3 次查看(过去 30 天)
显示 更早的评论
Med Future
2022-12-26
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);
采纳的回答
VBBV
2022-12-26
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 个评论
VBBV
2022-12-26
编辑:VBBV
2022-12-26
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
2022-12-26
@VBBV Error using vertcat
Dimensions of arrays being concatenated are not consistent.
Med Future
2022-12-26
VBBV
2022-12-26
编辑:VBBV
2022-12-26
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
2022-12-26
编辑:VBBV
2022-12-26
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
2022-12-26
@VBBV Not working, it just gives all values in array. No the print which i want
VBBV
2022-12-26
编辑:VBBV
2022-12-26
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
2022-12-27
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
2022-12-27
@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
2022-12-27
@Med Future, I cannot understand what the goal is. Please provide an illustration of what you'd like to accomplish.
Med Future
2022-12-28
@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
2022-12-28
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
2022-12-29
编辑:Adam Danz
2022-12-29
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
2022-12-29
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)