how can i change a particular range of data

조회 수: 28 (최근 30일)
Shikang Zhang
Shikang Zhang 2019년 7월 5일
편집: per isakson 2019년 7월 5일
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

답변 (1개)

Geoff Hayes
Geoff Hayes 2019년 7월 5일
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;

카테고리

Help CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by