In MATLAB, For Looping with String Array -
a similar question has been asked, still i'm looking solution.
in matlab, have array of states s:
s = {'indiana', 'texas', 'alabama'} time column vector: [120 30 20 40 50]' tornadoes column vector: [5 5 3 5 5]'
and need loop through array s following code below while placing each string in s in first line.
index = strcmpi(states,s) time = time(index) tornadoes = tornadoes(index) h = scatter(time,tornadoes)
so how can write code push each state in s generate plot each plot.
thanks, amanda
could simple this?
for ii = 1:numel(s) index = strcmpi(states, s{ii}) time = time(index) tornadoes = tornadoes(index) figure % make sure start new figure each time... h = scatter(time,tornadoes) title(['tornadoes in ' s{ii}]) end
Comments
Post a Comment