Clear Filters
Clear Filters

Storing Data in Zero Vectors

4 views (last 30 days)
Chameleon17
Chameleon17 on 25 Aug 2015
Answered: dpb on 25 Aug 2015
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 Comment
dpb
dpb on 25 Aug 2015
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?

Sign in to comment.

Answers (1)

dpb
dpb on 25 Aug 2015
Aren't you just looking for
LocationSquare(out5(1,:)) = out5(2,:);

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!