为了账号安全,请及时绑定邮箱和手机立即绑定

请问在matlab中有 nominal()这个函数吗?

请问在matlab中有 nominal()这个函数吗?

C PHP
慕桂英3389331 2022-04-15 18:11:28
matlab 中有 nominal()这个函数吗?具体情况?
查看完整描述

1 回答

?
桃花长相依

TA贡献1860条经验 获得超8个赞

有!

【函数概述】
nominal
Class: nominal

Construct nominal categorical array
expand all in page
The nominal and ordinal array data types might be removed in a future release. To represent ordered and unordered discrete, nonnumeric data, use the MATLAB® categorical data type instead.
Syntax
B = nominal(A)
B = nominal(A,labels)
B = nominal(A,labels,levels)
B = nominal(A,labels,[],edges)

Description
B = nominal(A) creates a nominal array B from the array A. A can be numeric, logical, character, categorical, or a cell array of strings. nominal creates the levels of B from the sorted unique values in A, and creates default labels for them.
B = nominal(A,labels) labels the levels in B using the character array or cell array of strings labels. nominal assigns labels to levels in B in order according to the sorted unique values in A.
B = nominal(A,labels,levels) creates a nominal array with possible levels defined by levels. levels is a vector whose values can be compared to those in A using the equality operator. nominal assigns labels to each level from the corresponding elements of labels. If A contains any values not present in levels, the levels of the corresponding elements of B are undefined.
B = nominal(A,labels,[],edges) creates a nominal array by binning the numeric array A with bin edges given by the numeric vector edges. The uppermost bin includes values equal to the right-most edge. nominal assigns labels to each level in B from the corresponding elements of labels. edges must have one more element than labels.
By default, an element of B is undefined if the corresponding element of A is NaN (when A is numeric), an empty string (when A is character), or undefined (when A is categorical). nominal treats such elements as "undefined" or "missing" and does not include entries for them among the possible levels for B. To create an explicit level for such elements instead of treating them as undefined, you must use the levels input, and include NaN, the empty string, or an undefined element.
You may include duplicate labels in labels in order to merge multiple values in A into a single level in B.

【用法举例】
Create and Label Nominal Arrays
Load the sample data.
load fisheriris;

Create a nominal array and display a summary of the data.
species = nominal(species);
summary(species)
setosa 50
versicolor 50
virginica 50

Create a nominal array from characters, and provide explicit labels.
colors1 = nominal({'r' 'b' 'g'; 'g' 'r' 'b'; 'b' 'r' 'g'},...
{'blue' 'green' 'red'})
colors1 =

red blue green
green red blue
blue red green

Create a nominal array from characters, and provide both explicit labels and an explicit order for display.
colors2 = nominal({'r' 'b' 'g'; 'g' 'r' 'b'; 'b' 'r' 'g'}, ...
{'red' 'green' 'blue'},{'r' 'g' 'b'})
colors2 =

red blue green
green red blue
blue red green

Create a nominal array from integer data, merging odd and even values into only two nominal levels. Provide explicit labels.
toss = nominal(randi([1 4],5,2),{'odd' 'even' 'odd' 'even'},1:4)
toss =

even odd
even even
odd odd
even even
odd even

查看完整回答
反对 回复 2022-04-19
  • 1 回答
  • 0 关注
  • 618 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号