how can i change a particular range of data

32 vues (au cours des 30 derniers jours)
Shikang Zhang
Shikang Zhang le 5 Juil 2019
Modifié(e) : per isakson le 5 Juil 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

Réponses (1)

Geoff Hayes
Geoff Hayes le 5 Juil 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;

Catégories

En savoir plus sur Data Types dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by