matlab conersion code needed

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 comentario

Sindar
Sindar el 5 de Jul. de 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

Iniciar sesión para comentar.

Respuestas (2)

raqib Iqbal
raqib Iqbal el 5 de Jul. de 2020

0 votos

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 el 5 de Jul. de 2020

0 votos

Change the endif to end
Change the endfor to end
I did not see anything else at the moment

2 comentarios

raqib Iqbal
raqib Iqbal el 10 de Jul. de 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
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Programming en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 5 de Jul. de 2020

Comentada:

el 17 de Jul. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by