How to insert text in a matrix - If function
Mostrar comentarios más antiguos
Dear All, In the following code I would like to insert 'good news', 'bad news', 'no news' instead of 1, 2, 3 in the "Announcement" matrix.
No idea how to insert text in a matrix (20X28 in this case) !
Many thanks in advance !
Pierre

1 comentario
Numeric matrices contain numeric data only.
You could:
- store the index in the numeric array, or
- use another kind of array, e.g. a cell array, table, etc.
But it is not possible to put a string (1xN character vector) into one element of a numeric matrix.
Respuesta aceptada
Más respuestas (1)
Andrei Bobrov
el 19 de Abr. de 2017
D is Divident
F is Forecasted_DPS
A = {'good news','bad news','no news'};
ii = (D >= 1.03*F) + (D <= .97*F)*2;
ii(ii == 0) = 3;
Announcements = A(ii);
1 comentario
Pierre Lonfat
el 20 de Abr. de 2017
Categorías
Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!