Combine two structure variables with different fields

版本 1.0.0 (1.1 KB) 作者: Taesam Lee
Combine two structure variables with different fields x.a, x.b y.c,y.d z=combinefield(x,y) z.a,z.b,z.c,z.d
17.0 次下载
更新时间 2019/4/15

查看许可证

function [Out]=combineField(A,B)
% Combine two structure variables into one
% A and B are stuructures want to include both
% Out: Output.

fnames=fieldnames(B);
for is=1:length(fnames)
Data=getfield(B,fnames{is});
A=setfield(A,fnames{is},Data);
end
Out=A;

引用格式

Taesam Lee (2025). Combine two structure variables with different fields (https://ww2.mathworks.cn/matlabcentral/fileexchange/71213-combine-two-structure-variables-with-different-fields), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2019a
兼容任何版本
平台兼容性
Windows macOS Linux
标签 添加标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0