Sort vector and obtain Boolean output based on the vector index

1 回表示 (過去 30 日間)
And Meng
And Meng 2019 年 5 月 2 日
編集済み: And Meng 2019 年 5 月 8 日
Hello,
I am designing a voltage balancing algorithm for converter application. It can be easily done by using a code-based MATLAB function block, but it requires some compiling time whenever I initilize the model. It would be interesting to me to build the function using blocks from simulink. I know there is a sort block from DSP System Toolbox, but now I am stuck on given values to the output signal based on vector index and n. Would be appreciated if you can provide me a example to implement this function using blocks.
v=rand(10,1);
n=5;
g=zeros(10,1);
[val,ind]=sort(v);%ascending
for i=1:n
g(ind(i))=1;
end

回答 (0 件)

カテゴリ

Help Center および File ExchangeMeasurements and Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by