I suspect this is homework, so I'm only going to give you a suggestion:
You should have a look at the colon operator and how you can assign values to an array with indexing.
2:4
A=rand(1,5);
A(4)=5
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!