how can i change a particular range of data

29 views (last 30 days)
I want to change 3 ranges of data. lets say i have a array that contains 10000 elements and i want to chage the 1st to 599th,600th to 1000th and 1001st to 10000th elements in an array. how can i achieve it.
thanks
PV =[112648;119180;.......117072;113687;114429;115560]
n=length(PV);
while n=(600:1000);
PV = 165000+zeros(1,401);
end
while n=(1:599);
PV=125000+zeros(1,599);
end
while n=(1001:10000);
PV=200000+zeros(1,9000);
end
PV

Answers (1)

Geoff Hayes
Geoff Hayes on 5 Jul 2019
Shikang - to access subsets of values in your array, you could do
PV = zeros(10000,1);
PV(1:599) = 125000;
PV(600:1000) = 165000;
PV(1001:end) = 200000;

Categories

Find more on Data Types in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!