call every row of matrix in each iteration

1 次查看(过去 30 天)
Hi I have matrix a with 1 row and 300 columns. this matrix is composed of randomly elements between 1 to 300:
a=randi(300,[1 300])
I reshaped it the matrix with 6 rows and 50 columns. I want to call in every time one of rows and use it like that:
for it=1:30
show=it
c=reshape(a,6,[])';
[l1 l2]=size(c);
rm=rem(it,l1);
if it<=l1;
k=c(it,:)
elseif it>l1
q=rm+1;
k=c(q,:)
end
for i=k
for j=k
d=sum(k)
end
end
end
I have two question please. why is (d) written four times in each iteration? can I chage it? can I vectorize this code? thank you.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by