필터 지우기
필터 지우기

Storing Data in Zero Vectors

조회 수: 1 (최근 30일)
Chameleon17
Chameleon17 2015년 8월 25일
답변: dpb 2015년 8월 25일
Good Evening, I have a very simple question which I have been struggling with.
LocationSquares = zeros (1:500)
out5 = Columns 1 through 7
35 36 38 46 48 49 50
735804 735788 735787 735816 735770 735788 735774
for Area = 1:500
if out5(1,i) == Area
Date = out5(2,i)
if out5(1,i) ~= Area
DateofOB = 0
end
end
end
LocationSquare(Area) = DateofOB
My out5 length varies for each year, not each location point has data for each year. I would like to store the date in the zero space of the corresponding Location Square, so 35 in the #35 zero space etc. Right now it's all a bit of a mess and I seem to be storing dates in each LocationSquare, but it isn't right there is a lot of repetition that shouldn't be occurring.
Any advice would be greatly appreciated.
  댓글 수: 1
dpb
dpb 2015년 8월 25일
LocationSquares = zeros (1:500);
will create a 500-D array of dimensions
size(LocationSquares)=[1,2,3,...,500];
This is highly unlikely what you intend; perhaps
LocationSquares = zeros(1,500);
maybe?

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

답변 (1개)

dpb
dpb 2015년 8월 25일
Aren't you just looking for
LocationSquare(out5(1,:)) = out5(2,:);

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by