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

35 次查看(过去 30 天)
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
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.

标签

Community Treasure Hunt

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

Start Hunting!

Translated by