Clear Filters
Clear Filters

Matlab矩阵处理。

2 views (last 30 days)
华纳公司注册开户【微8785092】
Answered: Chunru on 16 May 2023
大家好!我现在有个几千行的矩阵,按照第一列的ID从大到下进行排列得到的,现在想把第一列ID数量小于20的ID删除掉,请问怎么样才可以做到
谢谢大家!
例如:data = [1 2 2;1 0 2;2 1 4;2 3 6;2 5 6;3 2 1;3 6 5;3 7 8;3 6 4]
data =
1 2 2
1 0 2
2 1 4
2 3 6
2 5 6
3 2 1
3 6 5
3 7 8
3 6 4
将第一列数量小于3的行删除掉,变成
data =
2 1 4
2 3 6
2 5 6
3 2 1
3 6 5
3 7 8
3 6 4

Answers (1)

Chunru
Chunru on 16 May 2023
data = [1 2 2;1 0 2;2 1 4;2 3 6;2 5 6;3 2 1;3 6 5;3 7 8;3 6 4]
data = 9×3
1 2 2 1 0 2 2 1 4 2 3 6 2 5 6 3 2 1 3 6 5 3 7 8 3 6 4
data(data(:, 1)<3, :) =[]
data = 4×3
3 2 1 3 6 5 3 7 8 3 6 4

Categories

Find more on Resizing and Reshaping Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!