Hiya, Im trying to execute this for loop, but as well as changing the index, I also want to chnage the table that the original for loop is acting on.

I have four tables each with a different club name-

FMData_Test_BBSH_reordered

FMData_Test_NewCal_reordered

FMData_Test_3Wood_reordered

FMData_Test_Wooden_reordered

My original loop below works,

` for i=1:13 %Use rotation matrix to rotate the offline (x) and Carry distance (y)`

BBSH_x(i)=(FMData_Test_BBSH_reordered{i,3}.*cos(Theta_carry(1,1)))-(FMData_Test_BBSH_reordered{i,4}*sin(Theta_carry(1,1)));BBSH_y(i)=(FMData_Test_BBSH_reordered{i,3}.*sin(Theta_carry(1,1)))+(FMData_Test_BBSH_reordered{i,4}*cos(Theta_carry(1,1)));end

but rather than write this code out four times, each time changing the club name e.g.BBSH to the next club I was wondeirng if i could create another for loop to do this.

I have tried :

`Club_names={'BBSH','New Cal','Ping 3 Wood','Wooden'}; for ii=Club_names for i=1:13 %Use rotation matrix to rotate the offline (x) and Carry distance (y)ii_x(i)=(FMData_Test_ii_reordered{i,3}.*cos(Theta_carry(1,1)))-(FMData_Test_ii_reordered{i,4}*sin(Theta_carry(1,1)));ii_y(i)=(FMData_Test_ii_reordered{i,3}.*sin(Theta_carry(1,1)))+(FMData_Test_ii_reordered{i,4}*cos(Theta_carry(1,1)));end end `

but this doesnt work as Matlab says the varibale FMData_Test_ii_reordered is not defined.

Any suggestions greatly appreciated.

## Best Answer