MATLAB是有什么样名单COM prehension,因为它是在Python? [英] matlab Is there something like list comprehension as it is in python?

查看:135
本文介绍了MATLAB是有什么样名单COM prehension,因为它是在Python?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找像MATLAB中COM目录prehensions但是我无法找到在纪录片中这样的事。

在Python中它会像

  A = [I / 50在我的范围(50)]


解决方案

Matlab是很喜欢'量化'的。你会写你的例子是:

  A =(0:49)./ 50

Matlab的憎恨回路,因此名单COM prehension。这就是说,看看在 arrayfun 功能。

I am looking for something like list comprehensions in matlab however I couldnt find anything like this in the documentary.

In python it would be something like

A=[i/50 for i in range(50)]

解决方案

Matlab is very fond of 'vectorizing'. You would write your example as:

A = (0:49) ./ 50

Matlab hates loops and therefore list comprehension. That said, take a look at the arrayfun function.

这篇关于MATLAB是有什么样名单COM prehension,因为它是在Python?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆