필터 지우기
필터 지우기

Accessing nested array data

조회 수: 2 (최근 30일)
Kenneth Morley
Kenneth Morley 2014년 1월 27일
댓글: Amit 2014년 1월 27일
I would like to use a loop to find out which rows have 1's in a nested array. I will include a screenshot of what my data looks like and explain further:
I need to find out which row in 'surge15feet' has 1's as well as the row in the main variable 'counties.' I also would like to start the index in the last row of the surge variable and stop the loop and record the row when it encounters a 1.
The output I would like is 1x61 matrix (because of 61 counties) with a value between 7 and 0 corresponding to the first row in surge15feet that has a 1.
Thanks for the help! Kenny
  댓글 수: 2
Amit
Amit 2014년 1월 27일
Does in surge15feet, only 1 of the 7 columns have 1 for a given row?
Kenneth Morley
Kenneth Morley 2014년 1월 27일
편집: Kenneth Morley 2014년 1월 27일
surge15feet has 7 rows with 2792 columns. i want it to start with row 7 and check each column for a 1. If it has a 1 I want it to record a 7 for that county. If not I want it to go to row 6 and so on.

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

채택된 답변

Amit
Amit 2014년 1월 27일
out_new = zeros(1,61);
for j = 1:61
[x,y] = find(counties(j).surge15feet);
if (~isempty(x))
out_new(j) = max(x);
end
end
  댓글 수: 2
Kenneth Morley
Kenneth Morley 2014년 1월 27일
THAT IS IT!!! THANK YOU SOOOO MUCH!
Amit
Amit 2014년 1월 27일
I am sorry for the frustration (I dont know what I was thinking). I am deleting my old answer though.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by