Matlab學習------數值,變數和運算式,matlab------

來源:互聯網
上載者:User

Matlab學習------數值,變數和運算式,matlab------

(1)複數

複數輸入可以直接按照運算式輸入(用變數時盡量不要用),也可以在數字和虛部之間添加 *

舉例:

>> num=3+4inum =   3.0000 + 4.0000i>> num=3+4*inum =   3.0000 + 4.0000i
複數操作函數:
real(z) 求複數的實部;

imag(z)求複數的虛部;

abs(z)計算複數的模;

angle(z)計算複數的相角。

執行個體:

>> num=3+4*inum =   3.0000 + 4.0000i>> real(num)ans =     3>> imag(num)ans =     4>> abs(num)ans =     5>> angle(num)ans =    0.9273
(2)Inf和NaN

Inf是Infinity的縮寫,表示正無窮大,0做除數時要引入該常量;

NaN是Not-a-Number的縮寫,表示非數值量。

執行個體:

>> 1/0ans =   Inf>> 0/0ans =   NaN

(3)判斷輸入是否是Matlab關鍵字:iskeyword

>> iskeywordans =     'break'    'case'    'catch'    'classdef'    'continue'    'else'    'elseif'    'end'    'for'    'function'    'global'    'if'    'otherwise'    'parfor'    'persistent'    'return'    'spmd'    'switch'    'try'    'while'>> iskeyword whileans =     1>> iskeyword('while')ans =     1







matlab 怎給一個符號運算式中的變數賦值

D、P、Q是什麼啊?
 
matlab運算式多個變數怎同時賦值計算,那位大俠知道?

Multiple Substitutions:
subs(cos(a)+sin(b),{a,b},{sym('alpha'),2}) returns
cos(alpha)+sin(2)

使用subs就可以

然後用double命令就可以轉成數值了
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.