MATLAB Answers

0

how can i change a particular range of data

Asked by Shikang Zhang on 5 Jul 2019
Latest activity Edited by per isakson
on 5 Jul 2019
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

  0 Comments

Sign in to comment.

1 Answer

Answer by 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;

  0 Comments

Sign in to comment.