現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
How to print Value in next line of Table in App desiginer
4 ビュー (過去 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!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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 (한국어)