Editing a string
조회 수: 4 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
답변 (1개)
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
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
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 Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!