matlab中retern
时间: 2023-11-13 11:56:16 浏览: 27
在 MATLAB 中,return 语句用于从函数中返回一个值,并结束函数的执行。当函数执行到 return 语句时,它将返回指定的值并退出函数。如果没有指定返回值,则返回空数组 []。
例如,下面的函数将返回两个输入参数的和:
```
function c = add(a, b)
c = a + b;
return;
end
```
相关问题
def a_list(x): new_list=[i*i for i in x] retern new_list double=a_list([1,2,3,4]) print(double)
您的代码中有两个问题:
1. `retern` 应该是 `return`。
2. 在 `print(double)` 前面,`double` 没有被定义。应该是 `result` 或者 `double_list`。
修改后的代码如下:
```
def a_list(x):
new_list = [i*i for i in x]
return new_list
result = a_list([1, 2, 3, 4])
print(result)
```
输出结果为:
```
[1, 4, 9, 16]
```
相关推荐
![application/msword](https://img-home.csdnimg.cn/images/20210720083327.png)
![application/msword](https://img-home.csdnimg.cn/images/20210720083327.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)