当前位置:网站首页>[matlab]函数定义与使用
[matlab]函数定义与使用
2022-06-28 23:04:00 【おもいね】
matlb中函数的定义和使用和其他语言还是有很大差别的,本文就来介绍一下函数的基本用法
1. 基本结构
function y = test(x1,x2)
y = x1 + x2;
end
主要matlab中函数需要单独保存到一个与函数名相同的.m文件中,才能够条用使用
2.子函数
function y = test(x1,x2)
a = 1; % 全局变量,所以的子函数都能够调用
y = f1(x1) + x2;
function y2 = f1(x)
y2 = x + a;
end
end

3. 嵌套函数
实现累乘
function y = test(x)
if x == 1
y = 1;
else
y = x * test(x-1);
end
end
边栏推荐
- The Best of Many Worlds_ Dual Mirror Descent for Online Allocation Problems
- 【剑指Offer】50. 第一个只出现一次的字符
- 在QT进行cin(全网最清晰教程)
- With a monthly salary of 60000 yuan, such people began to be robbed after the Internet "reduced costs and increased efficiency"
- Sample code of using redis to realize the like function
- One card can sell tens of millions, and the business expansion is faster than that of players: you don't understand the Jianghu of star cards
- WEB API学习笔记1
- Panxiaoming, senior vice president of IC nansha|amd and President of Greater China: process, architecture and platform optimization break through the computing boundary
- Linq连表查询
- A password error occurred when docker downloaded the MySQL image to create a database link
猜你喜欢
Oracle set password complexity and timeout exit function

Wave picking of WMS warehouse management system module

LINQ linked table query

第二章 经典同步练习作业

Wechat red envelope cover making tutorial and use guide with link jump

老家出资,俞敏洪设立两支基金

This simple little function saves 213 hours for our production research team in half a year
![Leetcode 324 Swing sort II [tri double pointeur] le chemin du leetcode pour l'héroding](/img/41/b8ba8d771b7224eac1cc8c54fe9d29.png)
Leetcode 324 Swing sort II [tri double pointeur] le chemin du leetcode pour l'héroding

一文读懂,WMS仓储管理系统与ERP有什么区别

Panxiaoming, senior vice president of IC nansha|amd and President of Greater China: process, architecture and platform optimization break through the computing boundary
随机推荐
This simple little function saves 213 hours for our production research team in half a year
k线图基础知识图解——单根K线的含义
在线文本过滤小于指定长度工具
keil工程,程序写多后,RTT不能打印
C# 面试题目_20220627记录一下
【Flutter 问题系列第 71 篇】Flutter 中 Uint8List 和 Image 之间的相互转换
Complex nested object pool (4) -- manage the object pool of multi class instances and multi-stage instances
DBNN实验进展
The Best of Many Worlds_ Dual Mirror Descent for Online Allocation Problems
A password error occurred when docker downloaded the MySQL image to create a database link
数学知识:求组合数 I—求组合数
Online linear programming: Dual convergence, new algorithms, and regret bounds
油猴脚本学习
Qtcreater5.15.0 source code compilation process record
WEB API学习笔记1
[chapter 71 of the flutter problem series] mutual conversion between uint8list and image in flutter
Leetcode detailed explanation of stack type
Jointly explore digital technology and information security, and the fourth China Russia Digital Forum was successfully held
Cs5463 code module analysis (including download link)
在QT进行cin(全网最清晰教程)