Editing a string

4 visualizaciones (últimos 30 días)
Shounak Chakraborty
Shounak Chakraborty el 20 de Jun. de 2012
I have an array and i want to give a string input to a cell of the array. This is easy as long as my string is normal. But, i need to change the font size and bolden the string, and also change the background colour of my cell. Can someone please help me in doing this?

Respuestas (1)

Christoph
Christoph el 20 de Jun. de 2012
Hi Shounak,
what kind of cell are you talking about. And where do you want to print it? In my opinion the string itselfs shouldn't contain any style informations. I would set them in the object where you want to print it. For that reason you should read the help file to this object e.g. the property informations about that object.
good luck, CN
  3 comentarios
Christoph
Christoph el 21 de Jun. de 2012
Hi Shounak,
First of all m is not a matrix but a cellarray. it's important to differ those two data-types. How to color a text depends on where you want do display it. If you want to return it in the CommandWindow I don't know how to do this. But I know that it has to be possible just because an Error occours in red and a Warning in orange.
If you are using a figure to display your strings, you could use the command text(). It's pretty easy to color text. Just take a look to the text-properties in the documentation.
The next way , as you said before, is using an uitable. Don't be afraid of the "java" code. Coloring the font of all cells it not that hard, but coloring only the string of one cell seems to be a challenge. The problem with uicontrol objects in general is, that you can't use any text interpreter. For that reason its not possible to set the string color in the string itself.
To excel question i don't have a clue, just because I never did it. But many other user converte matlab data to excel and the other way around. I guess you should find some answers.
kind regards, CN
Walter Roberson
Walter Roberson el 21 de Jun. de 2012
Christoph is correct that font, bold, color are display attributes and are not part of a string itself.
Coloring individual cells in uitable:
http://www.mathworks.com/matlabcentral/answers/41173-changing-color-of-a-string-in-listbox-matlab-gui

Iniciar sesión para comentar.

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by