필터 지우기
필터 지우기

calculating size of column with specified value in the column

조회 수: 1 (최근 30일)
Anu Sharma
Anu Sharma 2022년 3월 19일
답변: Torsten 2022년 3월 19일
For calculating the values of e1 == 1, the code is
D1 = e1(e1(:,2)==1);
r1 = size(D1);
DDDx = r1(1,:);
I want to calculate the values for comparing 50 values
For example
D2 = e1(e1(:,2)==2);
r2 = size(D2);
DDDx2 = r2(1,:);
D3 = e1(e1(:,2)==3);
r3 = size(D3);
DDDx3 = r3(1,:);
.
.
.
D50 = e1(e1(:,2)==50);
r50 = size(D50);
DDDx50 = r50(1,:);

답변 (1개)

Torsten
Torsten 2022년 3월 19일
DDDx = zeros(50,1);
for i = 1:50
DDDx(i) = numel(e1(e1(:,2)==i));
end

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by