在MATLAB運算當中,我們常常需要求對數,在編寫M文件的過程中,我們也需要表示對數,下面我就通過一些示例介紹一下如何在MATLAB中求對數。
自然數對數 log(x)文章源自四五設計網-http://www.wasochina.com/52507.html
我們在MATLAB主窗口中輸入a1=log(2.7183),回車,我們可以看到a1近似為1,e約等于2.7183,文章源自四五設計網-http://www.wasochina.com/52507.html
文章源自四五設計網-http://www.wasochina.com/52507.html
設計學徒自學網www.sx1c.com文章源自四五設計網-http://www.wasochina.com/52507.html
以2為底數的對數 log2(x)文章源自四五設計網-http://www.wasochina.com/52507.html
我們在MATLAB主窗口中輸入a2=log2(4) ,回車,可以看到結果a2=2文章源自四五設計網-http://www.wasochina.com/52507.html
文章源自四五設計網-http://www.wasochina.com/52507.html
以10為底數的對數 log10(x)文章源自四五設計網-http://www.wasochina.com/52507.html
我們在MATLAB主窗口中輸入a3=log10(10) ,回車,可以看到結果a3=1文章源自四五設計網-http://www.wasochina.com/52507.html
文章源自四五設計網-http://www.wasochina.com/52507.html
丟塔游戲網www.diuta.com
其他底數對數logM(N)
這種對數需要進行一個簡單的中間變換,logM(N)=log(N)/log(M),這樣寫方便,用log10() 以及log2()都可以。我們在MATLAB主窗口中輸入如下命令:
a4=log(64)/log(8) 回車
我們可以看到 ,以8為底64的對數為2,


評論