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

11 visualizaciones (últimos 30 días)
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'

Respuesta aceptada

Steven Lord
Steven Lord el 29 de Oct. de 2019
Editada: Steven Lord el 29 de Oct. de 2019
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)

Más respuestas (1)

the cyclist
the cyclist el 29 de Oct. de 2019
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.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by