📄 00000045.htm
字号:
<?xml version="1.0" encoding="gb2312"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"/><title>Re: 请问matlab里有没有将向量左移右移的 xxhn </title></head><body><center><h1>BBS 水木清华站∶精华区</h1></center><a name="top"></a>发信人: FangQ (光芒之神), 信区: MathTools <br />标 题: Re: 请问matlab里有没有将向量左移右移的函数 <br />发信站: BBS 水木清华站 (Fri Oct 25 06:47:23 2002) <br /> <br />From: Peter J. Acklam (jacklam@math.uio.no) <br />Subject: Re: rotate function in Matlab <br />View: Complete Thread (3 articles) <br />Original Format <br />Newsgroups: comp.soft-sys.matlab <br />Date: 2000/07/10 <br /> <br /> <br />Peter Headless <headlesp@dial.pipex.com> writes: <br /> <br />><i> Is there a function in matlab which allows one to "rotate" a </i><br />><i> vector. By this I mean let: A=[1 2 3 4 5] </i><br />><i> </i><br />><i> then </i><br />><i> </i><br />><i> rotate(A,1) -> [5 1 2 3 4] </i><br />><i> rotate(A,2) -> [4 5 1 2 3] </i><br />><i> rotate(A,-1) -> [2 3 4 5 1] </i><br /> <br />The following is an excerpt from a document I am writing <br /> <br /> To shift and rotate the elements of a vector, use <br /> <br /> X([ end 1:end-1 ]); % shift right/down 1 element <br /> X([ end-k+1:end 1:end-k ]); % shift right/down k elements <br /> X([ 2:end 1 ]); % shift left/up 1 element <br /> X([ k+1:end 1:k ]); % shift left/up k elements <br /> <br /> Note that these only work if k is non-negative. If k is <br /> an arbitrary integer one may use something like <br /> <br /> X( mod((1:end)-k-1, end)+1 ); % shift right/down k elements <br /> X( mod((1:end)+k-1, end)+1 ); % shift left/up k element <br /> <br /> where a negative k will shift in the opposite direction of a <br /> positive k. <br /> <br />Given this, it should be easy to make the function you want. <br /> <br />Peter <br /> <br /> <br />【 在 AlfredPan 的大作中提到: 】 <br />∶<i> 或者循环移位的函数,谢谢 </i><br /> <br />-- <br /> <br />※ 来源:·BBS 水木清华站 smth.org·[FROM: 129.170.23.65] <br /><a href="00000044.htm">上一篇</a><a href="javascript:history.go(-1)">返回上一页</a><a href="index.htm">回到目录</a><a href="#top">回到页首</a><a href="00000046.htm">下一篇</a></h1></center><center><h1>BBS 水木清华站∶精华区</h1></center></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -