Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String 向现有结构添加更多字段名_String_Matlab_Struct - Fatal编程技术网

String 向现有结构添加更多字段名

String 向现有结构添加更多字段名,string,matlab,struct,String,Matlab,Struct,如果我有一个结构,句柄 handles = struct('a',1,'b',2,'c',3) 我还有一个字符串单元格和一个数字单元格 cell1 = {'d','e','f'}; cell2 = {4,5,6}; 如何将cell1中的字段名添加到具有cell2中的值的句柄中 虽然可能有更有效的方法,但首先想到的是利用: 返回: handles = a: 1 b: 2 c: 3 d: 4 e: 5 f: 6 对于这个例子来说,这可能是一种

如果我有一个结构,句柄

handles = struct('a',1,'b',2,'c',3)
我还有一个字符串单元格和一个数字单元格

cell1 = {'d','e','f'};
cell2 = {4,5,6};

如何将cell1中的字段名添加到具有cell2中的值的句柄中

虽然可能有更有效的方法,但首先想到的是利用:

返回:

handles = 

    a: 1
    b: 2
    c: 3
    d: 4
    e: 5
    f: 6

对于这个例子来说,这可能是一种非常有效的方法。@horchler我认为有一种很好的方法可以使用用
cell2struct(cell2,cell1,2)
构建的结构,但是我看到的所有结构合并功能都有很多开销。
handles = 

    a: 1
    b: 2
    c: 3
    d: 4
    e: 5
    f: 6