필터 지우기
필터 지우기

Loop Through a Cell Array

조회 수: 414 (최근 30일)
Amanda
Amanda 2013년 5월 8일
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
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.
Amanda
Amanda 2013년 5월 8일
Yes, I have column of data for each Rain and Sunshine in a spreadsheet. I really need help on this. I've been out this for awhile now.

댓글을 달려면 로그인하십시오.

채택된 답변

michael scheinfeild
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
Amanda
Amanda 2013년 5월 9일
편집: Amanda 2013년 5월 9일
Thanks you so much. I had almost given up that someone would come through. IT WORKED PERFECTLY.
Walter Roberson
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 CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by