Editing a string

3 次查看(过去 30 天)
Shounak Chakraborty
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?

回答(1 个)

Christoph
Christoph 2012-6-20
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 个评论
Christoph
Christoph 2012-6-21
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 2012-6-21
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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by