I have a scenario to create dynamic objects and also their variables by just entering the number of objects in for loop and the desired output is to initialize the variable name and assignment to corresponding array of position vector, in Matlab.
However I tried eval()
but it doesn't help me as i want to write a function and other complexities, I teried very much but could find the proper solution of my scenario.
What suggestions should according to my scenario, may be with function or without.
Edit1: Position vector is predefined. String for number the object, its not compulsory.
My Code:
function myFunc(n)
for ii=1:n
Obj(ii) = 'some string required with its number of ii';
Obj(ii).position=position(ii);
end
end