Basic question about loops
1 view (last 30 days)
Very basic question: why is this not working?
The error is: Unable to perform assignment because the left and right sides have a different number of elements.
millercommamatt on 29 Oct 2021
You could make use of genvarname, but this would work too.
for i = 2:5
eval(['Idx' num2str(i) ' = Idx(:,' num2str(i) ');']);
When you start using functions like genvarname and eval, it's usually a sign that you should be approaching your task in a different way.