matlab conersion code needed

2 visualizzazioni (ultimi 30 giorni)
raqib Iqbal
raqib Iqbal il 5 Lug 2020
Commentato: Walter Roberson il 17 Lug 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
#### what i want is this ocatave code output,,,and i want to do it in matlab please run it to see the output.. i need d matlab code of this octave code
  1 Commento
Sindar
Sindar il 5 Lug 2020
What does the code do? Most people answering questions here are interested in solving Matlab problems, and don't know every other language. If you can tell us what the code does, we can probably build it in Matlab. If you don't understand what the code does, ask an Octave forum

Accedi per commentare.

Risposte (2)

raqib Iqbal
raqib Iqbal il 5 Lug 2020
clear all
device=10:20
block=[1 16;2 18;3 17;4 21;5 23]
ROM = [device(1:size(block,1)).', sortrows(block, 2, 'descend')]

all i want is the from above 10 device 1st 5 device select the column2 max to min value of block matrix and the rest 5 value of device will select min 3 and more difference of value with column 2 .

o/p is like:-->
plz check the attached file for desired output

Walter Roberson
Walter Roberson il 5 Lug 2020
Change the endif to end
Change the endfor to end
I did not see anything else at the moment
  2 Commenti
raqib Iqbal
raqib Iqbal il 10 Lug 2020
cellular=1:100
resource=[1 8;2 12;3 7;4 18;5 17]
ROM = [cellular(1:size(resource,1)).', sortrows(resource, 2)];
ROM = ROM(ROM
(:, end) > 5, :)
what changes i have to do,,if i want "cellular value choose the resource column2 value with >5 randomly, and after choosing display will be like :--
1 column:-cellular value column
2nd column:--resource column1
3rd column:--resource 2nd column
Walter Roberson
Walter Roberson il 17 Lug 2020
Maybe
rc5 = find(resource(:,2) > 5);
rand5 = rc5(randi(length(rc5)));
randresource = resource(rand5, :);
output = [rand5, randresource];
This only creates one output line.... you did not indicate how many output lines need to be created. Also, it is better if you verify that this produces the kind of output that you want before I get into producing a whole table of these things.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by