Disp() is not showing the whole sentence in the command window
18 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Zeynab Mousavikhamene
le 29 Oct 2019
Commenté : the cyclist
le 29 Oct 2019
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'
0 commentaires
Réponse acceptée
Steven Lord
le 29 Oct 2019
Modifié(e) : Steven Lord
le 29 Oct 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)
1 commentaire
Plus de réponses (1)
the cyclist
le 29 Oct 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.
0 commentaires
Voir également
Catégories
En savoir plus sur JSON Format dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!