필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How to do this

조회 수: 1 (최근 30일)
Ram k
Ram k 2016년 5월 11일
마감: MATLAB Answer Bot 2021년 8월 20일
Suppose I have a sequence of n numbers
e=[5,4,45,63,22,22,1,12,3,2,2,16,14,14,16,17,1,19,21,15,32,32,27,27,43,41,7,8,13,23,23]
then for first 10 numbers i.e.
[5,4,45,63,22,22,1,12,3,2]
count numbers other than 1 to 5 and then divide by 10, i.e.
[45,63,22,22,12]
total 5, so result should be 5/10,now for first 20 numbers i.e.
[5,4,45,63,22,22,1,12,3,2,2,16,14,14,16,17,1,19,21,15]
then
[45,63,22,22,12,16,14,14,16,17,19,21,15]
total =13, so 13/20, like this for first 30,40,50...upto n numbers
and then plot figure with x axis points 0 10 20 30....n and y axis with 5/10,13/20..... how to do this

답변 (1개)

Guillaume
Guillaume 2016년 5월 11일
편집: Guillaume 2016년 5월 12일
Have you tried using a loop? It would be very straightforward.
Alternatively:
e=[5,4,45,63,22,22,1,12,3,2,2,16,14,14,16,17,1,19,21,15,32,32,27,27,43,41,7,8,13,23,23]
countinout = accumarray([ceil((1:numel(e))/10); 2-(e>5)]', e, [], @numel);
ratioin = cumsum(countinout(:, 1)) ./ (1:size(countinout(:,1)))' ./ 10;
plot((0:numel(ratioin)-1)*10, ratioin)
  댓글 수: 2
Ram k
Ram k 2016년 5월 11일
but how it is, y axis output should be less than or equal to 1, because number count should not exceed selected sequence length.
Guillaume
Guillaume 2016년 5월 12일
Sorry, made a mistake that I've now corrected.
As I said, you're better off using a simple loop. It will be a lot easier to understand and probably just as fast.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by