当前位置:网站首页>[matlab] function definition and use
[matlab] function definition and use
2022-06-28 23:09:00 【おもいね】
matlb The definition and use of functions in are quite different from those in other languages , This article will introduce the basic usage of functions
1. The basic structure
function y = test(x1,x2)
y = x1 + x2;
end
The main matlab The function in needs to be saved separately to a and With the same function name .m In file , To be able to use 
2. Subfunctions
function y = test(x1,x2)
a = 1; % Global variables , All subfunctions can call
y = f1(x1) + x2;
function y2 = f1(x)
y2 = x + a;
end
end

3. Nested function
Realize cumulative multiplication
function y = test(x)
if x == 1
y = 1;
else
y = x * test(x-1);
end
end
边栏推荐
- k线图基础知识图解——单根K线的含义
- 在线SQL转HTMLTable工具
- A password error occurred when docker downloaded the MySQL image to create a database link
- 月薪6万,互联网“降本增效”后,这类人开始被疯抢
- 数学知识:求组合数 I—求组合数
- Progress of dbnn experiment
- 生产环境sonarqube安装
- [sword finger offer] 50 First character that appears only once
- Websocket for im instant messaging development: concept, principle and common sense of mistakes
- Lecun predicts AgI: big model and reinforcement learning are both ramps! My world model is the new way
猜你喜欢
随机推荐
设计电商秒杀系统
Qsrand, srand random number generating function in qt5.15 has been discarded
运维排查-使用hcache插件排查Buffer/cache占用过高
手机办理股票开户安全性高吗?
【Word 教程系列第 2 篇】Word 中如何设置每页的表格都有表头
Serious internal entanglement in the we media industry: where should the enterprise we media go
他原来是这么刷题的!
复杂嵌套的对象池(4)——管理多类实例和多阶段实例的对象池
第四章 存储器管理练习
CIN at QT (the clearest tutorial in the whole network)
Business atlas in super factory
The Best of Many Worlds_ Dual Mirror Descent for Online Allocation Problems
如何使用伦敦金画出支撑阻力线
2022-06-28:以下golang代码输出什么?A:true;B:false;C:panic;D:编译失败。 package main import “fm
SqlServer复习
Is it safe to open a stock account by mobile phone?
What is the difference between WMS warehouse management system and ERP
[deep learning] (3) encoder mechanism in transformer, complete pytoch code attached
TDD和自动化测试
Counting sorting and stability of sorting




![Leetcode 324 swing sort ii[sort double pointer] the leetcode path of heroding](/img/41/b8ba8d771b7224eac1cc8c54fe9d29.png)




