cellfun名称-值对与名称"un"? [英] cellfun name-value pair with name 'un'?

查看:63
本文介绍了cellfun名称-值对与名称"un"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Matlab中心问题,我看到了以下将一系列字符串转换为数字的语法:

At a Matlab Central question, I saw the following syntax for converting a series of strings to numbers:

c = {'Name' '2/8' '3/7' '7/8'}
[c(1); cellfun(@str2num,c(2:end),'un',0).']

通过处理代码,我发现末尾的点是不必要的.但是,我尚未找到有关名为"un"的cellfun名称/值对的含义的任何文档.既可以在网上的2015b文档中找到,也可以在我的本机2015a文档页面中找到,分别在cellfun和str2num下查找.有人能对此有所启示吗?

From mucking with the code, I found that the dot near the end is unnecessary. However, I haven't found any documentation on the meaning of the cellfun name-value pair named 'un'. This is both in the 2015b documentation on the web and my native 2015a doc pages, looking under both cellfun and str2num. Would anyone be able to shed some light on that?

在一个与非常相关的问题上,我试图找到一个用于将表变量从字符串转换为数字的习惯用法时发现了上述问题(对于非数字项,可能使用NaN).最优雅的方法是什么?

And on a very related question, I found the above while trying to find a code idiom for converting a table variable from string to numerical (perhaps with NaN for nonumerical entries). What is the most elegant way to do this?

推荐答案

感谢Andras Deak& David解释了"un"名称/值对实际上是"UniformOutput"名称/值对的简称.

Thank you to Andras Deak & David for explaining that the 'un' name-value pair is actually the short name for the 'UniformOutput' name-value pair.

对于原始帖子中问题的第二部分,str2double(myTable.myStringVariableColumnName)似乎可以正常工作.

As for the 2nd part of the question in the original post, str2double(myTable.myStringVariableColumnName) seems to work fine.

这篇关于cellfun名称-值对与名称"un"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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