当前位置:网站首页>[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
边栏推荐
- Leetcode detailed explanation of stack type
- See fengzhixia | FENGZikai, the originator of Guoman, for exclusive sale of Digital Collections
- Business atlas in super factory
- Is it safe and reliable to open a securities account in changtou school?
- SqlServer复习
- 运维排查-使用hcache插件排查Buffer/cache占用过高
- Chapter V virtual memory exercise
- Cs5463 code module analysis (including download link)
- 大三,不简单啊!
- Qsrand, srand random number generating function in qt5.15 has been discarded
猜你喜欢

强大的开源API接口可视化管理平台-YApi

Realization of 2D code generation in micro build low code

keil工程,程序写多后,RTT不能打印

笔记

第四章 存储器管理练习

C interview questions_ 20220627 record

【深度学习】(3) Transformer 中的 Encoder 机制,附Pytorch完整代码
![[deep learning] (3) encoder mechanism in transformer, complete pytoch code attached](/img/cb/d385bee7a229e8d11f5fa8af66311f.gif)
[deep learning] (3) encoder mechanism in transformer, complete pytoch code attached

Websocket for im instant messaging development: concept, principle and common sense of mistakes

2022 PMP project management examination agile knowledge points (4)
随机推荐
Undefined symbol main (referred from entry9a.o).
[gateway development] handle the IP address segment represented by CIDR when NGX nested Lua
Is it safe and reliable to open a securities account in changtou school?
Prometeus 2.36.0 新特性
网上注册股票开户很困难么?在线开户是安全么?
【Word 教程系列第 1 篇】如何去除 Word 表格中的箭头
The love digital smart 2022 summit opens, sharing data strategy and building data-driven organization methodology
小样本利器2.文本对抗+半监督 FGSM & VAT & FGM代码实现
Panxiaoming, senior vice president of IC nansha|amd and President of Greater China: process, architecture and platform optimization break through the computing boundary
How to use London gold to draw support resistance line
带链接跳转的微信红包封面制作教程和使用指南
LeCun预言AGI:大模型和强化学习都是斜道!我的世界模型才是新路
TDD case practice
[flutter issues Series title 71] Mutual Conversion between uint8list and Image in flutter
With a monthly salary of 60000 yuan, such people began to be robbed after the Internet "reduced costs and increased efficiency"
[数学建模]Matlab非线性规划之fmincon()函数
笔记
Mathematical knowledge: finding combinatorial number I - finding combinatorial number
2022-06-28:以下golang代码输出什么?A:true;B:false;C:panic;D:编译失败。 package main import “fm
Encounter with avita 11: long lost freshness under strong product power