matlab conersion code needed

조회 수: 5 (최근 30일)
raqib Iqbal
raqib Iqbal 2020년 7월 5일
댓글: Walter Roberson 2020년 7월 17일
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에서 Octave에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by