Filter löschen
Filter löschen

Storing Data in Zero Vectors

4 Ansichten (letzte 30 Tage)
Chameleon17
Chameleon17 am 25 Aug. 2015
Beantwortet: dpb am 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 Kommentar
dpb
dpb am 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?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

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

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by