matlab基本函数的输入输出,Matlab函数的基本使用
Part 1Matlab函數(shù)的基本概念
1.MATLAB的腳本和函數(shù)都是包含MATLAB命令的.m文件。
2.腳本沒有參數(shù)的輸入輸出,函數(shù)有。
3.使用函數(shù),需要一個(gè)腳本或者函數(shù)召喚它。
1. MATLAB scripts and functions are .m files containing MATLAB commands.
2. The script has no input and output parameters, but the function has.
3. To use a function, you need a script or function to call it.
Part 2查看內(nèi)嵌函數(shù)
如查看平均數(shù)函數(shù)
Such as viewing the average function
通過上述內(nèi)嵌函數(shù),我們可以看到函數(shù)設(shè)置的五個(gè)要素:
Through the above embedded function, we can see the five elements of the function setting:
1.函數(shù)使用的關(guān)鍵字是function
2.文件名與函數(shù)名字是一致的
3.(x,dim,flag)是輸入,y是輸出
4.dim和flag為局部變量
5.MATLAB需要有找到該函數(shù)的路徑
1. The keyword used by the function is function
2. The file name is consistent with the function name
3. (x, dim, flag) is input, y is output
4.dim and flag are local variables
5. MATLAB needs a path to find the function
Part 3用戶自定義函數(shù)
如自定義自由落體位移函數(shù)
Such as custom free fall displacement function
首先新建腳本,輸入函數(shù),保存為與函數(shù)名相同名字的文件。
First create a new script, enter the function, and save it as a file with the same name as the function.
注意:元素與元素之間是點(diǎn)乘。
然后就可以調(diào)用該函數(shù)了。
Note: There is a dot product between elements.
Then you can call the function.
調(diào)用內(nèi)嵌函數(shù)和自定義函數(shù)是一致的。例如可以計(jì)算兩組數(shù)據(jù)。
Calling built-in functions is consistent with custom functions. For example, two sets of data can be calculated.
Part 4多輸入、多輸出函數(shù)
如定義下列函數(shù)
Such as defining the following function
然后調(diào)用函數(shù)Then call the function
我們會(huì)發(fā)現(xiàn)結(jié)果不對(duì),多輸入多輸出函數(shù)的正確使用方法如下:
We will find that the result is wrong. The correct way to use the multiple-input multiple-output function is as follows:
Part 5沒有input函數(shù)
例如,在命令欄輸入一個(gè)華氏溫度,然后計(jì)算成攝氏溫度。
For example, enter a Fahrenheit temperature in the command bar, and then calculate it to Celsius.
Isempty:判斷該函數(shù)是否為空
Num2str:將數(shù)值轉(zhuǎn)化為字符串
然后運(yùn)行程序,不停的輸入,結(jié)果如下:
Isempty: Determine whether the function is empty
Num2str: Convert a value to a string
Then run the program, keep typing, the results are as follows:
參考資料:百度百科、B站郭彥甫Matlab教程、谷歌翻譯
本文由LearningYard學(xué)苑原創(chuàng),如有侵權(quán),請(qǐng)聯(lián)系刪除。
舉報(bào)/反饋
總結(jié)
以上是生活随笔為你收集整理的matlab基本函数的输入输出,Matlab函数的基本使用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c100道
- 下一篇: SBUS协议数据演示