How to extract odd numbered elements.

조회 수: 11 (최근 30일)
Rares-Ioanid
Rares-Ioanid 2023년 5월 22일
답변: KSSV 2023년 5월 22일
Generate a population of 10000 normally distributed elements with mean 2 and dispersion 3. Generate 1000 indexes at random from which only the odd ones are chosen to create a data sample.
Any idea or solution is helpful. My main issue is that I do not know how to extract only the odd numbered elements.

답변 (1개)

KSSV
KSSV 2023년 5월 22일
A = 1:10 ;
% Pick only odd elements
idx = mod(A,2)~=0 ;
A(idx)
ans = 1×5
1 3 5 7 9

카테고리

Help CenterFile Exchange에서 Random Number Generation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by