I have asked the question as http://www.mathworks.com/matlabcentral/answers/3748-how-to-make-a-loop-for-end. Matt fig helped me this: x=[1.6,2.7,3.5,4.4,5.2,6.8,7.9,8.4,9.1,10.2]; N = length(x); % The largest number. Change to whatever… a = 1; % The starting point. Change to 3,5… whatever S = 3; n = zeros(1,floor((N-a)/(S))+1); % Pre-allocate the array… for ii = 1:length(n) n(ii) = x(S*(ii)+(a-S)); end Now,I want to make a new loop for S (S=1:length(x)),that gets the value of S from 1 to length(x).So I can get every value of n when the S is different. How are the codes about?
MATLAB: How to make loop
loopMATLAB
Best Answer