MATLAB: Selecting only half a row of an array

arraysmultiplication

Hey guys,
Im fairly new to MATLAB and I'm just having a problem working out how to multiply ony half a row of my array.
I was hoping someone could help me out.
Basic example
a = 1×5
1
2
3
4
5
6
How would I select 2, 3, 4 and multiply it by 3
and how would I select 4, 5, 6 and multiply it by 3

Best Answer

Read about MATLAB array indexing, instead of asking very simple basic questions.
If a is an narray of size 1x5.
a(1:2) % gives first two arrays
a(1) % gives first
a(end) % gives last element
a(2:4)
iwant = a(1:3)*3 ; % pick first three and multiply by 3