Info

This question is closed. Reopen it to edit or answer.

selection of specific value of a column from a matrix

1 view (last 30 days)
cellular=1:6
resource=[1 6;2 12;3 7;4 3;5 17]
what are the syntaxes are to use if i want cellular value select row with min column2 value 5 and more??????
output like
1 1 6
2 3 7
3 2 12
and so on...................

Answers (1)

madhan ravi
madhan ravi on 4 Jul 2020
Use the same code I gave you in previous code , but remove 'descend' .
  5 Comments
raqib Iqbal
raqib Iqbal on 4 Jul 2020
clear all;
device = [10:1:20];
block = [1 16;2 18; 3 17; 4 21; 5 23];
block_sort = sortrows(block,-2);
ROM (:,1) = device;
for i =1:length(device)
if i<=size(block,1)
ROM (i,2:3) = block_sort(i,:)
else
[j,_] = find(block_sort>=device(i)+3)
ROM (i,2:3) = block_sort(max(j),:)
endif
endfor
####sir what i want is this ocatave code output,,,and i want to do it in matlab please run it to see the output..
madhan ravi
madhan ravi on 5 Jul 2020
ROM = [cellular(1:size(resource,1)).', sortrows(resource, 2)];
ROM = ROM(ROM(:, end) > 5, :)

This question is closed.

Community Treasure Hunt

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

Start Hunting!