看板 MATLAB 關於我們 聯絡資訊
請問各位大大 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://www.ptt.cc/bbs/MATLAB/M.1439890154.A.99E.html
tn00364361: imag(thi) ~= 008/18 17:59
mp19990920: ~isreal(thi)08/18 19:18
shine87076: t大的意思是 if imag(thi)~=0 嗎08/18 20:51
profyang: 如果今天a和b都是複數 加起來因為數值誤差造成thi只是很08/18 21:05
profyang: 接近是實數 這時最好用if abs(imag(thi))<err08/18 2106
profyang: err是你自己定的一個夠小的數08/18 21:06
tn00364361: 樓上正解08/18 21:18
※ 編輯: shine87076 (42.72.41.6), 08/19/2015 13:33:19
profyang: a和b都是實數你thi=sqrt(a^2+b^2)怎麼可能是虛數... 08/19 19:55
sunev: 樓上點出盲點! 08/19 20:34