假设我们 有a = [1 2 3 4]和。找出是 的 转移而不是 的转移的最简单方法是什么?b = [3 4 1 2]c = [1 2 4 3]baca
矩阵有一些功能吗?
我建议你使用strfind. 如果a是 的旋转b,那么a应该在里面找到[b b]:
strfind([b b],a)
ans =
3
>> strfind([c c],a)
ans =
[]
You can rotate a size(a) times and check if the newly rotated vector is the same with b:
for i = 1:length(a),
a = a([end 1:end-1])
if(a == b)
disp('true')
end
end