matlab conersion code needed

5 vues (au cours des 30 derniers jours)
raqib Iqbal
raqib Iqbal le 5 Juil 2020
Commenté : Walter Roberson le 17 Juil 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 commentaire
Sindar
Sindar le 5 Juil 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

Connectez-vous pour commenter.

Réponses (2)

raqib Iqbal
raqib Iqbal le 5 Juil 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 le 5 Juil 2020
Change the endif to end
Change the endfor to end
I did not see anything else at the moment
  2 commentaires
raqib Iqbal
raqib Iqbal le 10 Juil 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 le 17 Juil 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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Octave dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by