Converting string to integer - indexing and multiple trials
Ältere Kommentare anzeigen
I have 120 trials in one Matlab file, all trials are separate within the file and look similar to that of trial1.mat (attached). I am importing this Matlab file into Python and indexing into the correct spot with
cue_times = trial(['BehavioralCodes']['CodeTimes'], dtype=int)
**I know this is not a Python platform, and that is not my question, I am merely explaining what I'm doing when I get the error I am getting.**
I get the error that the list indices must be integers or slices, not str
I need to convert 'CodeTimes' within 'BehavioralCodes' in each trial (each trial is saved individually like trial1) from a string to an integer.
I have tried:
code_times = str2num('CodeTimes') but that gives me an empty array so I am definitely doing something wrong.
I am not sure how to index into the correct space and then to include all trials (perhaps a for loop?). Any help would be greatly appreciated!
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
