matlab conersion code needed

1 次查看(过去 30 天)
raqib Iqbal
raqib Iqbal 2020-7-5
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 个评论
Sindar
Sindar 2020-7-5
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

请先登录,再进行评论。

回答(2 个)

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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 MATLAB Coder 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by