matlab基本函数的输入输出,Matlab函数的基本使用
Part 1Matlab函數的基本概念
1.MATLAB的腳本和函數都是包含MATLAB命令的.m文件。
2.腳本沒有參數的輸入輸出,函數有。
3.使用函數,需要一個腳本或者函數召喚它。
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查看內嵌函數
如查看平均數函數
Such as viewing the average function
通過上述內嵌函數,我們可以看到函數設置的五個要素:
Through the above embedded function, we can see the five elements of the function setting:
1.函數使用的關鍵字是function
2.文件名與函數名字是一致的
3.(x,dim,flag)是輸入,y是輸出
4.dim和flag為局部變量
5.MATLAB需要有找到該函數的路徑
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用戶自定義函數
如自定義自由落體位移函數
Such as custom free fall displacement function
首先新建腳本,輸入函數,保存為與函數名相同名字的文件。
First create a new script, enter the function, and save it as a file with the same name as the function.
注意:元素與元素之間是點乘。
然后就可以調用該函數了。
Note: There is a dot product between elements.
Then you can call the function.
調用內嵌函數和自定義函數是一致的。例如可以計算兩組數據。
Calling built-in functions is consistent with custom functions. For example, two sets of data can be calculated.
Part 4多輸入、多輸出函數
如定義下列函數
Such as defining the following function
然后調用函數Then call the function
我們會發現結果不對,多輸入多輸出函數的正確使用方法如下:
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函數
例如,在命令欄輸入一個華氏溫度,然后計算成攝氏溫度。
For example, enter a Fahrenheit temperature in the command bar, and then calculate it to Celsius.
Isempty:判斷該函數是否為空
Num2str:將數值轉化為字符串
然后運行程序,不停的輸入,結果如下:
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學苑原創,如有侵權,請聯系刪除。
舉報/反饋
總結
以上是生活随笔為你收集整理的matlab基本函数的输入输出,Matlab函数的基本使用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c100道
- 下一篇: matlab人脸追踪,求大神帮助我这个菜