'for' loops in app designer methods have a parsing problem
Show older comments
I've been debugging a simple app designer project. I have a list of strings that are country names. I want to delete all duplicates so I have a simple property 'ii' that is an index for traversing the list so I referred to it as 'app.ii' in a 'for' loop that is inside a working method. Matlab won't let me do it and says there is a parsing error at '.' It will let me use 'app.ii' in a 'while' loop or 'if' statement but as soon as I type it in a 'for' loop a red line appears under the period. 'ii' is a declared property of the app. Anyone have an idea what this seemingly straightforward 'for' loop is doing wrong?
Accepted Answer
More Answers (1)
Try this to remove duplicates
% Remove duplicates from arrays of countries.
% Using character arrays.
countries = {'USA', 'Belgium', 'UK', 'USA', 'Japan'}
uniqueCountries = unique(countries)
% Using strings.
countries2 = ["USA", "Belgium", "UK", "USA", "Japan"]
uniqueCountries2 = unique(countries2)
Categories
Find more on Loops and Conditional Statements 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!