<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>牧羊人的方向 &#187; Matlab</title>
	<atom:link href="http://www.sweetytang.com/archives/tag/matlab/feed" rel="self" type="application/rss+xml" />
	<link>http://www.sweetytang.com</link>
	<description>追风少年,且听风吟,风犹在耳,牧羊人的方向</description>
	<lastBuildDate>Mon, 08 Sep 2014 05:13:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Matlab中rem()和mod()函数的区别</title>
		<link>http://www.sweetytang.com/archives/52.html</link>
		<comments>http://www.sweetytang.com/archives/52.html#comments</comments>
		<pubDate>Mon, 16 Jul 2012 10:57:06 +0000</pubDate>
		<dc:creator>牧羊人</dc:creator>
				<category><![CDATA[师夷长技]]></category>
		<category><![CDATA[Matlab]]></category>

		<guid isPermaLink="false">http://www.sweetytang.com/?p=52</guid>
		<description><![CDATA[rem(x,y):求整除x/y的余数 mod(x,y):求模 rem(x,y)=x-y.*fix(x./y);  (fix()向0取整) mod(x,y)=x-y.*floor(x./y); （floor()向左取整） 如果x和y的符号相同（同为‘+’，同为‘-’），那么rem(x,y)=mod(x,y)（正数与正数，负数与负数，取整结果两个函数效果一样） 如果x和y的符号相反，那么mod(x,y)=rem(x,y)+y(正数与负数的取整，看你希望得到什么结果就选择用什么函数) 当正数与负数取余时，当得到的余数结果的符号希望跟除数(x)一样，用rem()函数；当得到的余数结果的符号希望跟被除数(y)一样，用mod()函数 例如： rem(3,2)=1;mod(3,2)=1; rem(-3,-2)=-1;mod(-3,-2)=-1; rem(3,-2)=1;mod(3,-2)=-1; rem(-3,2)=-1;mod(-3,2)=1; mod(3,2)=rem(3,2)=1; mod(3,-2)=rem(3,-2)-2=1-2=-1; mod(-3,2)=rem(-3,2)+2=-1+2=1;]]></description>
			<content:encoded><![CDATA[<p>rem(x,y):求整除x/y的余数</p>
<p>mod(x,y):求模</p>
<p>rem(x,y)=x-y.*fix(x./y);  (fix()向0取整)</p>
<p>mod(x,y)=x-y.*floor(x./y); （floor()向左取整）<span id="more-52"></span></p>
<p>如果x和y的符号相同（同为‘+’，同为‘-’），那么rem(x,y)=mod(x,y)（正数与正数，负数与负数，取整结果两个函数效果一样）</p>
<p>如果x和y的符号相反，那么mod(x,y)=rem(x,y)+y(正数与负数的取整，看你希望得到什么结果就选择用什么函数)</p>
<p>当正数与负数取余时，当得到的余数结果的符号希望跟除数(x)一样，用rem()函数；当得到的余数结果的符号希望跟被除数(y)一样，用mod()函数</p>
<p>例如：</p>
<p>rem(3,2)=1;mod(3,2)=1;</p>
<p>rem(-3,-2)=-1;mod(-3,-2)=-1;</p>
<p>rem(3,-2)=1;mod(3,-2)=-1;</p>
<p>rem(-3,2)=-1;mod(-3,2)=1;</p>
<p>mod(3,2)=rem(3,2)=1;</p>
<p>mod(3,-2)=rem(3,-2)-2=1-2=-1;</p>
<p>mod(-3,2)=rem(-3,2)+2=-1+2=1;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sweetytang.com/archives/52.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
