Loop for adding matrix elements

조회 수: 8(최근 30일)
Lev Mihailov
Lev Mihailov 2020년 7월 28일
댓글: dpb 2020년 7월 29일
Hello! I have a matrix, in each column I need to add several elements (rows) of different lengths to the end of the column
X=rand(577,1289) % my matrix
LimitOneStep = 0.012 % the step I need to summarize
% columlim
for i=1:10 % start of cycle
count=0 % basic counter for measuring column length (row count)
sum=0 % counter for the sum of one part of a column (add multiple rows)
LimitOne=1 % the number of lines that I need to summarize according to the step above
for j=1:544 % this is a measure of the read limit on the column (544 is the number of rows for each column)
while count<LimitOne % the very condition when my number of steps does not exceed one. it's about 83 rows per column
count=count+LimitOneStep % summarizes the step to service
countS=ceil(count/LimitOneStep ) % allows you to get an integer, because in a loop, the index cannot be a fractional number
Index in position 2 exceeds array bounds (must not exceed 1289).
Error in SumX(line 890)
writes this error, help me figure it out
  댓글 수: 7
dpb 2020년 7월 29일
And what logic explains how one would arrive at that result from the input, pray tell?
Simply repeating nonworking code does nothing to explain the underlying rationale behind the desire.
"Can't code what can't explain"

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


Community Treasure Hunt

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

Start Hunting!

Translated by