Subscripted assignment between dissimilar structures within a table
显示 更早的评论
I'm trying to populate a table that includes a column of 1x1 structs. First I create the table as follows:
tableSize = [500 10];
varNames = ["Name","LocationName","LLA","SystemType","PlatformType",...
"Antenna","Rx","Tx","Gain_dBi","AdditionalInfo"];
varTypes = ["string","string","cell","string","string",...
"string","logical","logical","double","struct"];
rxTable = table('Size',tableSize,'VariableTypes',varTypes,'VariableNames',varNames)
rxTable =
500×10 table
Name LocationName LLA SystemType PlatformType Antenna Rx Tx Gain_dBi AdditionalInfo
_________ ____________ ____________ __________ ____________ _________ _____ _____ ________ ______________
<missing> <missing> {0×0 double} <missing> <missing> <missing> false false 0 1×1 struct
rxTable(1,:).AdditionalInfo
ans =
struct with no fields.
Then, after defining all the inputs, I try to populate a row as follows:
additionalInfo = struct('URL','www.google.com', 'SNR', 10, 'NumElements', 1, 'NumChannels', 1);
rxTable(i,:) = {name, locationName, LLA, systemType, platformType, antenna,...
Rx, Tx, gain, additionalInfo};
All the variables are successfully populated as expected except the struct in the last column. It gives me the following error
Subscripted assignment between dissimilar structures.
I'm guessing it has to do with trying to replace the initially defined empty 1x1 struct with a populated 1x1 struct, but I can't figure out how to get arround it.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!