Borrar filtros
Borrar filtros

remove the functionality of special characters

9 visualizaciones (últimos 30 días)
avram alter
avram alter el 30 de Dic. de 2019
Editada: John D'Errico el 30 de Dic. de 2019
I have a cell array that contains the '%' character
C = {000000020F0D0%, 0000000281830%, 0071803F01CF0%, 0071803F6AA40%};
the problem is that it commnets out everything after it. How do I avoid this?

Respuesta aceptada

John D'Errico
John D'Errico el 30 de Dic. de 2019
Editada: John D'Errico el 30 de Dic. de 2019
What do you think the % symbol does in MATLAB? Answer: when not inside quotes (so a string) it creates a comment.
What do either of these strings of characters mean in MATLAB?
000000020F0D0
000000020F0D0%
Answer: Essentially nothing. It is just a list of characters. Inside a cell array as you are trying to put it, they do not even form a valid MATLAB syntax.
I might guess that perhaps you want them to be strings of some ilk, representing whatever it is you want them to mean, thus:
C = {'000000020F0D0%', '0000000281830%', '0071803F01CF0%', '0071803F6AA40%'};
But as you want to create that cell array, it is just a syntax error waiting to happen.
You cannot arbitrarily turn off the functionality of a % in MATLAB, any more than you can hope that MATLAB will know what it is that you might want MATLAB to do with that statement.
Since you appear to be creating these statements, then you probably need to create them as strings, thus with enclosing quotes, IF you want to create them as cell arrays.

Más respuestas (1)

Jonah Pearl
Jonah Pearl el 30 de Dic. de 2019
What are the % signs for? I think you can just make the contents of the cell array into characters:
C = {'000000020F0D0%', '0000000281830%', '0071803F01CF0%', '0071803F6AA40%'};
If you ever need to get just the part out before the % sign, you can use regexp:
part = regexp('000000020F0D0%', '(\w*)%', 'tokens');
  1 comentario
avram alter
avram alter el 30 de Dic. de 2019
Editada: avram alter el 30 de Dic. de 2019
those signs are part of an incoming serial tag. they are a necessary part of the tag's identity.
thanks for the help, it's a bit of an obvious question, but I am not very good at this.

Iniciar sesión para comentar.

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by