フィルターのクリア

Disp() is not showing the whole sentence in the command window

14 ビュー (過去 30 日間)
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2019 年 10 月 29 日
コメント済み: the cyclist 2019 年 10 月 29 日
I used disp() fucntion to show warning on the command window. Apparently, the sentence is longer than one line so it is not showing it completely in the command window. How can I mangae this?
note=['warning: the value of parameter taken from foldre name is not consisitant with json parameter value',param_table.name(jjj) ];
disp(note)
Output:
'warning: the value of parameter taken from fold…' 'DEATH_AGE_AVG'

採用された回答

Steven Lord
Steven Lord 2019 年 10 月 29 日
編集済み: Steven Lord 2019 年 10 月 29 日
Your param_table is likely a struct whose name field contains a cell array.
>> jjj = 1;
>> param_table.name{1} = 'DEATH_AGE_AVG';
>> note=['warning: the value of parameter taken from foldre name is not ', ...
'consisitant with json parameter value', param_table.name(jjj) ];
>> disp(note)
Because of this, note is a 1-by-2 cell array and when displaying cell arrays with disp only a certain portion of each cell is displayed. Otherwise one cell with a large amount of text could scroll the display of other cells off the top of the Command Window's scroll buffer.
You can avoid this by making note a char vector. Extract the contents of the cell stored in the name field rather than the cell itself. Note that I used {} instead of () to extract the data from param_table.name when I constructed note.
>> jjj = 1;
>> param_table.name{1} = 'DEATH_AGE_AVG';
>> note=['warning: the value of parameter taken from foldre name is not ', ...
'consisitant with json parameter value', param_table.name{jjj} ];
>> disp(note)
  1 件のコメント
the cyclist
the cyclist 2019 年 10 月 29 日
Ah. I like this theory better than the one in my solution.

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

その他の回答 (1 件)

the cyclist
the cyclist 2019 年 10 月 29 日
Did you use square or curly brackets when you defined "note"?
Square brackets will concatenate the two strings, and should display everything. Curly brackets will define a cell array of two strings, and truncate the display.
note_curly = {'warning: the value of parameter taken from foldre name is not consisitant with json parameter value','DEATH_AGE_AVG'};
note_square = ['warning: the value of parameter taken from foldre name is not consisitant with json parameter value','DEATH_AGE_AVG'];
disp(note_curly)
disp(note_square)
The code you posted had square brackets, but the output is what I would expect from curly.

カテゴリ

Help Center および File ExchangeJSON Format についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by