Matlab 将结构转换为数组
下面是一个简化的 考虑Matlab中的数据结构:Matlab 将结构转换为数组,matlab,Matlab,下面是一个简化的 考虑Matlab中的数据结构: struct(1).left=1;struct(2).left=2;struct(3).left=3; 现在我想把它复制到一个整数数组中 K>> arrayL(1:3)=struct.left 阿莱尔= 1 1 1 为什么只将struct.left的第一个元素放入arrayL?如何将整个结构(1:3)复制到arrayL中,使其包含1,2,3? 谢谢我现在手头没有matlab,但是试试arrayL=[struc
struct(1).left=1;struct(2).left=2;struct(3).left=3;
现在我想把它复制到一个整数数组中
K>> arrayL(1:3)=struct.left
阿莱尔=
1 1 1
为什么只将struct.left的第一个元素放入arrayL?如何将整个结构(1:3)复制到arrayL中,使其包含1,2,3?
谢谢我现在手头没有matlab,但是试试
arrayL=[struct.left]
(因为struct.left
本身会返回3个单独的答案,每个元素对应struct
)。我现在手头没有matlab,但请尝试arrayL=[struct.left]
(因为struct.left
本身会返回3个单独的答案,每个答案对应于struct
中的每个元素)。您可以尝试使用cell2mat函数