Octave 用八度表示字母三元表?

Octave 用八度表示字母三元表?,octave,Octave,我有一个字母三元表,它将概率与字母的每一个三元相关联,例如“thr”。我不确定用八度表示这样一个表的最佳方式是什么,这样查找就有效了 有什么建议吗?您可以使用类似于关联数组的数据结构,恰当地命名为struct() 请注意,setfield()函数未就位;它返回一个新的结构。您可以使用类似于关联数组的数据结构,恰当地命名为struct() 请注意,setfield()函数未就位;它返回一个新的结构 % Create a new struct trigrams = struct(); % Add

我有一个字母三元表,它将概率与字母的每一个三元相关联,例如“thr”。我不确定用八度表示这样一个表的最佳方式是什么,这样查找就有效了


有什么建议吗?

您可以使用类似于关联数组的数据结构,恰当地命名为
struct()


请注意,
setfield()
函数未就位;它返回一个新的结构。

您可以使用类似于关联数组的数据结构,恰当地命名为
struct()

请注意,
setfield()
函数未就位;它返回一个新的结构

% Create a new struct
trigrams = struct();

% Add an item explicitly, by using the format 'struct.key',
% where 'key' can be an arbitrary key
trigrams.length = 0;

trigrams.thr = 0.02;
trigrams.length += 1;

% Use setfield() when you don't know the key beforehand (e.g. if you're reading
% the values from a file, etc.)
trigramkey = 'hi';

trigrams = setfield(trigrams, trigramkey, 0.0007);
trigrams.length += 1;

% Likewise, use getfield() when you need a value dynamically
workingprob = getfield(trigrams, trigramkey);

% You can also check the existence of a key
hi_exists = isfield(trigrams, 'hi');

% By the way, you don't actually have to track the length like I've been doing
trigramlength = length(fieldnames(trigrams));