필터 지우기
필터 지우기

how to store values in Matrix based on the output of some iteration

조회 수: 1 (최근 30일)
chan
chan 2021년 8월 2일
답변: KSSV 2021년 8월 2일
I have run a code in which the loop keeps on running until it is false. Suppose the loop runs for (for i=1:count) where count =randi(5) .i have a problem in putting the output in the matrix. i want the result 3,2,3,2,3 to be stored in a matrix and want to find the number of occurances of each element. How to store this values in a matrix??? Could anyone suggest me some hint
Result:
the max value is node 3
the max value is node 2
the max value is node 3
the max value is node 2
the max value is node 3

답변 (1개)

KSSV
KSSV 2021년 8월 2일
iwant = zeros(count,1) ;
for i = 1:count
iwant(i) = randi(5) ;
end
To get the occurences read about unique.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by