Did you know you can use most emoticons in text objects?
Most emoticons are just unicode characters. Using them as characters in Matlab is as simple as finding their numeric representation and then converting the numeric value back to character. Not all emoticons are convertible in Matlab.
Here's a secret message with emoticons. Use char(x) to decode it.
x = [79 77 71 33 32 55357 56878 32 104 97 118 101 32 121 111 ... 117 32 117 112 100 97 116 101 100 32 116 111 32 77 97 116 ... 108 97 98 32 55358 56595 32 114 50 48 50 49 97 32 121 101 116 32 8265];
Happy St. Patrick's Day!
fig = figure('MenuBar','none','Color', [0 .62 .376]); % Shamrock green ax = axes(fig,'Units','Normalized','Position',[0 0 1 1]); axis(ax,'off') axis(ax,'equal') hold(ax,'on') xlim(ax,[-1,1]); ylim(ax,[-1,1]) text(ax, 0, 0, char(9752), 'VerticalAlignment','middle','HorizontalAlignment','center','FontSize', 200) str = num2cell('Happy St Patrick''s day!'); th = linspace(-pi/2,pi/2,numel(str)); txtHandle = text(ax,sin(th)*.8, cos(th)*.8, str, 'VerticalAlignment','middle','HorizontalAlignment','center','FontSize', 25); set(txtHandle,{'rotation'}, num2cell(rad2deg(-th'))) thr = 0.017; rotateCCW = @(xyz)([cos(thr) -sin(thr) 0; sin(thr), cos(thr), 0; 0 0 1]*xyz.').'; while all(isvalid(txtHandle)) newposition = rotateCCW(vertcat(txtHandle.Position)); set(txtHandle,{'position'}, mat2cell(newposition,ones(numel(txtHandle),1),3), ... {'rotation'}, num2cell([txtHandle.Rotation].'+thr*180/pi)) drawnow() end
댓글 수: 8
I see nobody has posted the know-it-all correction yet, so I'll bite the bullet: emoticons are things like ¯\_(ツ)_/¯ and :), while emoji are the pictures in the Unicode standard (see the YouTube videos by Tom Scott for the interesting back story).
Also, this is one of the few areas where you can see Matlab uses UTF-16 to encode chars. Interestingly, the readlines function fails to read them correctly and replaces them by string(char(26)) (at least on R2020b, I haven't tested it on R2021a yet, this happens for all two-word characters as far as I can tell)
Can you expand on what you mean that not all emoji are convertible to Matlab? You mean the display is not correct?
If you want to pick your emoji from a visual list of all of them, you can see them all here:
https://emojipedia.org/people/
Click on the emoji you want, then click on the Copy button to copy it to the clipboard and then you can paste it wherever you want. Many/most places, like MATLAB Answers, will recognize them and display them properly.
Awesome post Adam :) And yes I have!