How to delete all strings with NaN in Struct
Show older comments
Hello,
I've been wasting hours trying to remove the rows in the struct variable ID with value = 'NaN' in osmScenarios.trafficLight.ID.
ID is a string in this case.
For example:
arep = strrep(osmScenarios.trafficLight.ID,'NaN','')
error: Too many input arguments.
I know that probably something is wrong with me using that struct but what the change to happen in that struct. No, I need it to happen in that struct.
Please help. i don´t know what to do anymore.
Best regards
3 Comments
KSSV
on 1 Aug 2023
Attach your struct variable.
"strrep(osmScenarios.trafficLight.ID,'NaN','') error: Too many input arguments."
Most likely the field TRAFFICLIGHT is non-scalar, thus the dot-indexing TRAFFICLIGHT.ID produces a comma-separated list with multiple arrays. If that is the case, you might need to use a loop+indexing, or perhaps ARRAYFUN... what exactly you need depends on the sizes and arrangement of the arrays stored in that structure, which you have not explained nor uploaded. Not uploading your actual data will significantly slow down your getting a useful solution.
"I've been wasting hours trying to remove the rows in the struct variable ID with value = 'NaN' ..."
It is unclear how STRREP would help you to "remove the rows in the struct variable" because it does not do anything like "remove the rows" of a structure, it simply replaces some characters with some other characters (just as its documentation states). So as well as providing your actual data, you need to explain more clearly what you want to achieve, preferably with both the input data and expected output data.
Volker
on 3 Aug 2023
Accepted Answer
More Answers (0)
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!