正如标题所说,我正在寻找一个这个动态版本,但我无法弄清楚如何做到这一点。在这种情况下,r = 30,并且情况之间的差异是5(我< = 5,我< = 10,1 < = 15等)有人可以帮助我吗?我怎样才能以更动态的方式来写这个?
for i = 1:r
if i <= 5
a_m_o(length(a_m_o)+1) = m_o(i) - m_o(1)
elseif i <= 10
a_m_o(length(a_m_o)+1) = m_o(i) - m_o(6)
elseif i <= 15
a_m_o(length(a_m_o)+1) = m_o(i) - m_o(11)
elseif i <= 20
a_m_o(length(a_m_o)+1) = m_o(i) - m_o(16);
elseif i <= 25
a_m_o(length(a_m_o)+1) = m_o(i) - m_o(21);
elseif i <= 30
a_m_o(length(a_m_o)+1) = m_o(i) - m_o(26);
end
if a_m_o(i)<0
a_m_o(i) = a_m_o(i) + 400;
end
end