作者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/m.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