Loop Through a Cell Array
443 ビュー (過去 30 日間)
古いコメントを表示
I have a csv file with the data (ignore whitespaces below only for readable):
State, Rain, Sunshine,
Indiana, 52, 25,
Kansas, 45, 22,
Georgia 35, 55,
Texas 22, 30,
Arizona 60, 12,
I need to create a for loop that will step through the cell array State:
State = {'Indiana','Kansas','Georgia','Texas','Arizona'}
for n = 1:numel(states)
and generate a separate plot for Rain vs. Sunshine for each state.
Thanks,
Amanda
2 件のコメント
Walter Roberson
2013 年 5 月 8 日
Do you have multiple entries for each state? Are they ordered somehow, such as there being one entry per state per period and the next occurrence of the state indicates the next period? It is difficult to generate a useful plot based on one data point.
採用された回答
michael scheinfeild
2013 年 5 月 9 日
編集済み: Walter Roberson
2013 年 5 月 9 日
for k=1:length(State)
curstate=State{k};
//now go on
plot(curstate(1),curstate(2),'ro')
end
2 件のコメント
Walter Roberson
2013 年 5 月 9 日
Are you wanting to produce one graph per state, or are you wanting to produce one graph that has one dot per state? There are other more efficient ways if you want one dot per state combined in a graph.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Multidimensional Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!