How can I remove quotes from my struct?

5 vues (au cours des 30 derniers jours)
Livia Legnazzi
Livia Legnazzi le 17 Juin 2018
Commenté : Stephen23 le 17 Juin 2018
I have a struct like in the picture (EEG_all.event with 4 fields: type, latency, urevent, duration-each one is 123 rows). How can I remove the quotes from "type"?

Réponse acceptée

Ameer Hamza
Ameer Hamza le 17 Juin 2018
If by remove quotes, you mean convert it to numeric format then try
temp = num2cell(str2double({EEG_all.event.type}));
[EEG_all.event.type] = temp{:};
  5 commentaires
Livia Legnazzi
Livia Legnazzi le 17 Juin 2018
I used a code which was not written by me and which is pretty complicated so I prefer to add this rather than change the original code
Stephen23
Stephen23 le 17 Juin 2018
@Livia Legnazzi: your question and this answer are about two different things: you asked how to remove the quotation marks (you can't, because they are not part of the char vector, just how it is displayed), and then you accepted an answer which shows how to convert a char vector to a numeric value. Converting from character to numeric has absolutely nothing to do with "removing" quotation marks.

Connectez-vous pour commenter.

Plus de réponses (1)

Image Analyst
Image Analyst le 17 Juin 2018
You can't. That's just how the variable editor displays it. You can't get rid of it anymore than you can get rid of the little icons on the column headers at the top of the columns, or the grid lines. They're just part of how MATLAB chooses to display the information. Note that the quotes are not in the data, they're there just for display to indicate that the field value is a string rather than a number. So
length(EEG_all.event(10).type)
will show 3, not 5, meaning that no quotes are in the string.

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by