一、假设现在我们需要创建在matlab的m脚本文件中一个mxn的数组,数组中的元素都是一样的结构体。
假设结构体的内容包括delta_s, kappa, sigma; 结构体数组的大小为500x1.
首先初始化一个结构体control1:control1.delta_s = 0; control1.kappa = 0; control1.sigma = 0;
然后初始化一个空的元组control11并保存结构体control1:control11 = cell(1); control11{1} = control1;
最后将元组control11大小进行修改获得100x1大小的元组controls:hc_rs_controls = repmat(control11,1,500);
二、结构体数组中的结构体包含子结构体的情况采用类似的处理方法
start.x = 0; start.y = 0; start.theta = 0; start.kappa = 0;
cstart.start = start; cstart.left = false; cstart.forward = false; cstart.regular = false;
cstart.kappa = 0; cstart.kappa_inv = 0; cstart.sigma = 0; cstart.xc = 0; cstart.yc = 0;
cstart.radius = 0; cstart.mu = 0; cstart.sin_mu = 0; cstart.cos_mu = 0; cstart.delta_min = 0;
q.x = 0; q.y = 0; q.theta = 0; q.kappa = 0;
path1.start = start; path1.end = start; path1.kappa = 0; path1.sigma = 0; path1.length = Inf; path1.type = 'g';
path1.qi1 = q; path1.qi2 = q; path1.qi3 = q; path1.qi4 = q;
path1.cstart = cstart; path1.cend = cstart; path1.ci1 = cstart; path1.ci2 = cstart;
path11 = cell(1); path11{1} = path1; path = repmat(path11,1,16);