Combine two structure variables with different fields
Version 1.0.0 (1.14 KB) by
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
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;
Cite As
Taesam Lee (2024). Combine two structure variables with different fields (https://www.mathworks.com/matlabcentral/fileexchange/71213-combine-two-structure-variables-with-different-fields), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2019a
Compatible with any release
Platform Compatibility
Windows macOS LinuxCategories
- AI, Data Science, and Statistics > Statistics and Machine Learning Toolbox > Descriptive Statistics and Visualization > Descriptive Statistics >
Find more on Descriptive Statistics in Help Center and MATLAB Answers
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0 |