Create a vector with data from a structure named with the field name
4 次查看(过去 30 天)
显示 更早的评论
Hi, I want to créate a vector, currently I've named manually using the next way:
Actual_Gear_Ratio = [];
>> for i=1:length(x)
Actual_Gear_Ratio=[Actual_Gear_Ratio; x(i).Actual_Gear_Ratio]; % read/concatenate
end
What I want to avoid is the necessity to name every vector, I have a cell array (myVars) with all the variable names but I haven't be able to créate all the vectors automatically. I've tried things like this:
for i=1:length(x)
for j=1:length(myVars)
myVars(1,j)=[myVars(1,j); x(i).myVars(1,j)]; % read/concatenate
end
end
Hope you can help me. Thanks
1 个评论
回答(2 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!