matlab conersion code needed
1 view (last 30 days)
Show older comments
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 Comment
Sindar
on 5 Jul 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
Answers (2)
Walter Roberson
on 5 Jul 2020
Change the endif to end
Change the endfor to end
I did not see anything else at the moment
2 Comments
Walter Roberson
on 17 Jul 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.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!