Removing a TEX arrow symbol from String
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jason
el 13 de Feb. de 2020
Comentada: Jason
el 13 de Feb. de 2020
hello.
I have several text objects on a plot that I want to alter. Its actually created using the TEX interpreter in the text function:
txt='E4E'
txt=horzcat('\leftarrow',txt);
text(app.UIAxes,x,y,txt,'Color',cl,'FontSize',12,'Interpreter', 'tex','HorizontalAlignment','left','VerticalAlignment','middle');
Sometimes the rightarrow is used.
Text (532 E4E\rightarrow) with properties:
String: '532 E4\rightarrow'
FontSize: 20
FontWeight: 'normal'
FontName: 'Helvetica'
Color: [0 1 0]
HorizontalAlignment: 'left'
Position: [320 5100 0]
Units: 'data'
I want to remove the arrows, and have tried this.
htext=findobj(app.UIAxes,'Type','text');
n=numel(htext);
for i=1:n
h=htext(i)
s1='\rightarrow'
s2='\leftarrow'
newStr=erase(h.String,s1); %Delete S1 if present
newStr=erase(h.String,s1); %Delete S2 if present
h.String=newStr; %reassign
end
But it only does one arrow orientation?
0 comentarios
Respuesta aceptada
Subhadeep Koley
el 13 de Feb. de 2020
Your code is almost correct but, before erasing you need to check whether the h.String contains \leftarrow or \rightarrow. Use the code below.
htext=findobj(app.UIAxes, 'Type', 'text');
n = numel(htext);
for i = 1:n
h = htext(i);
s1 = '\rightarrow';
s2 = '\leftarrow';
if contains(h.String, s1,'IgnoreCase',true)
newStr = erase(h.String,s1);
h.String = newStr;
else
newStr = erase(h.String,s2);
h.String = newStr;
end
end
Más respuestas (0)
Ver también
Categorías
Más información sobre Characters and Strings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!