123
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
function D = normalize_text(D)
|
||||
%NORMALIZE_TEXT 把 load 出来的字符矩阵还原成字符串列表。
|
||||
% scipy.io.savemat 会把 Python 的字符串列表写成三维 char 数组(或 char 矩阵),
|
||||
% MATLAB 侧读回来是 char,不能按 {i} 取值,这里统一转成 cellstr。
|
||||
|
||||
fn = fieldnames(D);
|
||||
for k = 1:numel(fn)
|
||||
v = D.(fn{k});
|
||||
if ischar(v) && ndims(v) > 2
|
||||
D.(fn{k}) = cellstr(v);
|
||||
elseif isstruct(v)
|
||||
D.(fn{k}) = normalize_text(v);
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user