Calculate a return (base index)
古いコメントを表示
I would like to calculate the column Base Index , for each particular ID is id(i)/id(base)*100, where id(base) is the first item FOR EACH id
ID Value Base Index
1 10 100
1 15 150 (e.g.15/10*100)
1 4 40
2 3 100
2 20 667
2 8 267
2 11 367
3 25 100
with this code I only get right answers for first id...how can I deal with the last one?
bvalue(1)=100;
for i=2:length(id)-1
if id(i)~=id(i-1) & id(i)==id(i+1)
bvalue(i)=100;
else
bvalue(i)=value(i)/value(id(i))*100;
end
end
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Whos についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!