help me to write this code

 采纳的回答

Try this:
m = randi(9, 30000, 3); % Sample data.
lastColumn = m(:, end);
targetValue = 5; % Whatever...
% Find where the last column matches our target value.
matches = lastColumn == targetValue;
fprintf('Found %d matches of %d (out of %d) in the last column.\n', ...
sum(matches), size(m, 1), targetValue);
% Extract the matching rows up until but not including the last column.
m2 = m(matches, 1:end-1);
[rows2, columns2] = size(m2)
% Get starting and ending rows to split this up into 10 submatrices.
rStart = round(linspace(1, rows2-rows2/10, 10))
rEnd = [rStart(2:end)-1, rows2]

更多回答(0 个)

类别

标签

Community Treasure Hunt

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

Start Hunting!

Translated by