Converting Colour RGB into a string with padding and gaps
조회 수: 3 (최근 30일)
이전 댓글 표시
Hello, I am accessing the color of lineplots and want to output them to a text area
b=ax.Children;
n=numel(b);
ReportMessage(app,'******* Graphics Objects [RGB] (1=newest) *******');
for i=1:n
T=b(i).Type; %Text or line?
C=b(i).Color %Get line colour
Lg=b(i).DisplayName;
end
These colours "C" are doubles in the form
C =
0 0.4470 0.7410
when i want to create a string from them, if I use this in the loop:
ReportMessage(app,[num2str(i,'%02d'),': ',T,', color: ',num2str(C,'%.2f'),' Lgd: ',Lg]);
I get:
01: line, color: 0.000.450.74 Lgd: 30.0 (^{o}C), 20s Delay
02: line, color: 1.000.540.00 Lgd: 27.5 (^{o}C), 20s Delay
03: line, color: 0.250.800.54 Lgd: 25.0 (^{o}C), 20s Delay
04: line, color: 0.830.140.14 Lgd: 22.5 (^{o}C), 20s Delay
where the colour RGB have no spaces between each component.
How can I get Color, so the 1st line would become (Note I need gaps between the components RGB)
01: line, color: 0.000 0.447 0.741 Lgd: 30.0 (^{o}C), 20s Delay
T
his is my ReportMessage Function
function ReportMessage(app,msg)
currString=get(app.MessagesTextArea,'Value');
%currString=[{char(msg)};currString]; %add to top of message box
currString=[currString; {char(msg)}]; %add to bottom of message box
app.MessagesTextArea.Value=currString;
drawnow;
scroll(app.MessagesTextArea,'bottom');
end
댓글 수: 0
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Title에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!