Effacer les filtres
Effacer les filtres

remove the functionality of special characters

9 vues (au cours des 30 derniers jours)
avram alter
avram alter le 30 Déc 2019
Modifié(e) : John D'Errico le 30 Déc 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?

Réponse acceptée

John D'Errico
John D'Errico le 30 Déc 2019
Modifié(e) : John D'Errico le 30 Déc 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.

Plus de réponses (1)

Jonah Pearl
Jonah Pearl le 30 Déc 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 commentaire
avram alter
avram alter le 30 Déc 2019
Modifié(e) : avram alter le 30 Déc 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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by