Issues with looping in structure: variable in the name
I am loading one Excel spreadsheet with 11 tabs. The 11 tabs are named fl1, fl2,… fl11.
The spreadsheet is currently loaded into a structure named flight_data. I don’t like the way it is organized, so I want to create a 11 new structures: somename1, somename2,….somename11.
I think the code will show how I’m trying to structure my data. The goal is to have 11 strutures that look like this:
%my loop that doesn’t work
for i = 1:11
fpro(i).loc7.x = flight_data.fpro{i}(:,1)
end
%my structure setup
fpro(i).name = ‘Flight Profile {i}’;
fpro(i).loc7.x = flight_data.fl{i}(:,1)
fpro(i).loc9.x = flight_data.fl{i}(:,4)
fpro(i).loc10.x = flight_data.fl{i}(:,7)
fpro(i).loc7.y = flight_data.fl{i}(:,2)
fpro(i).loc9.y = flight_data.fl{i}(:,5)
fpro(i).loc10.y = flight_data.fl{i}(:,8)
fpro(i).loc7.z = flight_data.fl{i}(:,3)
fpro(i).loc9.z = flight_data.fl{i}(:,6)
fpro(i).loc10.z = flight_data.fl{i}(:,9)I am loading one Excel spreadsheet with 11 tabs. The 11 tabs are named fl1, fl2,… fl11.
The spreadsheet is currently loaded into a structure named flight_data. I don’t like the way it is organized, so I want to create a 11 new structures: somename1, somename2,….somename11.
I think the code will show how I’m trying to structure my data. The goal is to have 11 strutures that look like this:
%my loop that doesn’t work
for i = 1:11
fpro(i).loc7.x = flight_data.fpro{i}(:,1)
end
%my structure setup
fpro(i).name = ‘Flight Profile {i}’;
fpro(i).loc7.x = flight_data.fl{i}(:,1)
fpro(i).loc9.x = flight_data.fl{i}(:,4)
fpro(i).loc10.x = flight_data.fl{i}(:,7)
fpro(i).loc7.y = flight_data.fl{i}(:,2)
fpro(i).loc9.y = flight_data.fl{i}(:,5)
fpro(i).loc10.y = flight_data.fl{i}(:,8)
fpro(i).loc7.z = flight_data.fl{i}(:,3)
fpro(i).loc9.z = flight_data.fl{i}(:,6)
fpro(i).loc10.z = flight_data.fl{i}(:,9) I am loading one Excel spreadsheet with 11 tabs. The 11 tabs are named fl1, fl2,… fl11.
The spreadsheet is currently loaded into a structure named flight_data. I don’t like the way it is organized, so I want to create a 11 new structures: somename1, somename2,….somename11.
I think the code will show how I’m trying to structure my data. The goal is to have 11 strutures that look like this:
%my loop that doesn’t work
for i = 1:11
fpro(i).loc7.x = flight_data.fpro{i}(:,1)
end
%my structure setup
fpro(i).name = ‘Flight Profile {i}’;
fpro(i).loc7.x = flight_data.fl{i}(:,1)
fpro(i).loc9.x = flight_data.fl{i}(:,4)
fpro(i).loc10.x = flight_data.fl{i}(:,7)
fpro(i).loc7.y = flight_data.fl{i}(:,2)
fpro(i).loc9.y = flight_data.fl{i}(:,5)
fpro(i).loc10.y = flight_data.fl{i}(:,8)
fpro(i).loc7.z = flight_data.fl{i}(:,3)
fpro(i).loc9.z = flight_data.fl{i}(:,6)
fpro(i).loc10.z = flight_data.fl{i}(:,9) for, structures, sytax MATLAB Answers — New Questions