matlab conersion code needed
1 回表示 (過去 30 日間)
古いコメントを表示
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
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 件)
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 件のコメント
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.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!