Storing Data in Zero Vectors

4 次查看(过去 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