matlab - Running a for loop through 5 data structs
问题描述
I have been searching for simple solutions for running a for loop through my structs, but the code I've generated gives me an error indicating that my struct isn't defined within the function. I have 20 structs (sss(1:20) in example), and within each of these, I have 5 structs I want to combine.
My problem stated simply is that I want everywhere there is an "x" in the for function to be run through 20 times for the numbers 1-20 for each different struct name. This is probably a simple problem, but I can't find the simple solution. Help would be much appreciated
I've tried using "fieldnames" function, but it didn't work. perhaps I wasn't using it properly?
for x = 1:20
a = union(s1.ss1.sss_{x}.d1,s1.ss1.sss_{x}.d2)
b = union(a,s1.ss1.sss_{x}.d3)
c = union(b,s1.ss1.sss_{x}.d4)
newstruct_(x) = union(c,s1.ss1.sss_{x}.d5)
end
解决方案
推荐阅读
- oracle - 在 Oracle 函数中正确使用 sum 和 case 作为循环
- blockchain - 恢复区块链中丢失的数据
- javascript - 用于存储用户上传的事件的数组或子集合
- android - 在回收站视图中预加载项目(回收站内的回收站)
- android - 不显示地图数据 - Xamarin.Forms.Maps
- python - BadRequestKeyError
- java - 无法在编辑配置中选择我的应用
- python - imp 模块已弃用
- dart - 使用颤振在 cloudfirestore 中创建实时收藏夹
- android - 在 NestedScrollView 中的 RecyclerView 中延迟加载视图