作者shine87076 (小琏)
看板MATLAB
标题if 条件式描述虚数
时间Tue Aug 18 17:29:11 2015
请问各位大大
thi=sqrt(a^2+b^2)
if thi是虚数
frptint(thi=0%5.4\n,thi)
end
请问条件式要怎麽叙述*thi是虚数*
P.S.变数a,b都是角度所以是一个实数!
谢谢~
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 223.136.217.26
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/MATLAB/M.1439890154.A.99E.html
1F:→ tn00364361: imag(thi) ~= 008/18 17:59
2F:→ mp19990920: ~isreal(thi)08/18 19:18
3F:→ shine87076: t大的意思是 if imag(thi)~=0 吗08/18 20:51
4F:推 profyang: 如果今天a和b都是复数 加起来因为数值误差造成thi只是很08/18 21:05
5F:→ profyang: 接近是实数 这时最好用if abs(imag(thi))<err08/18 2106
6F:→ profyang: err是你自己定的一个够小的数08/18 21:06
7F:推 tn00364361: 楼上正解08/18 21:18
※ 编辑: shine87076 (42.72.41.6), 08/19/2015 13:33:19
8F:推 profyang: a和b都是实数你thi=sqrt(a^2+b^2)怎麽可能是虚数... 08/19 19:55
9F:推 sunev: 楼上点出盲点! 08/19 20:34