I’m trying to vectorize a bit of Matlab code that requires input from two adjacent members of an array. Essentially:
x=1:10;
for i=1:9
y(i) = x(i)+x(i+1);
end
Is there a way to vectorize this code so that I don’t need to use the for loop?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Do I understand this right? Is this what you need?
?