How create a model in SIMULINK using Embedded Matlab Function?

1 回表示 (過去 30 日間)
Emmanuel Luevano
Emmanuel Luevano 2012 年 10 月 24 日
回答済み: bilal cheb 2021 年 6 月 17 日
Hi, somebody can help saying me what blocks need, to convert the next code into SIMULINK and create a code C?
n = 50;
xy = 10*rand(n,2);
popSize = 60; numIter = 1e4;
showProg = 1;
showResult = 1;
a = meshgrid(1:n);
dmat = reshape(sqrt(sum((xy(a,:)-xy(a',:)).^2,2)),n,n);
[optRoute,minDist] = tsp_ga(xy,dmat,popSize,numIter,showProg,showResult);

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 10 月 24 日
編集済み: Azzi Abdelmalek 2012 年 10 月 24 日
you can use Embedded function ( called with recent versions: Matlab function)from Simulink/user defined function. But you have to check if all function are allowed by this block
  4 件のコメント
Emmanuel Luevano
Emmanuel Luevano 2012 年 10 月 29 日
thanks for you time Azzi, this example has help me to give me an idea, could you be kind to explain to me how I must declare the function DMAT, which is an array to calculate the distance point to point, this operation should be done in another block, or should I do it within the same block TSP?
any kind of information will be of great help, greetings!!!
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 10 月 29 日
編集済み: Azzi Abdelmalek 2012 年 10 月 29 日
Emmanuel, that depends on what you want to do with dmat, you use one matlab function or more, it's your choice. I can't tell because I do'nt know what exactly, you are doing? I will think about it

サインインしてコメントする。

その他の回答 (2 件)

ABISHA  P
ABISHA P 2017 年 1 月 9 日
Hi, how to convert or to make blocks in simulink to do standard deviation using sliding window with the math script code ? T=2;F=1/T; t=linspace(-T,T,100); x =sin(2*pi*F*t)+0.5*randn(1,length(t)); subplot(2,2,1) plot(t,x) N = length(x); % length of the signal
% element count in each window n = conv(ones(1, N), ones(1, w), 'same');
% calculate s vector s = conv(x, ones(1, w), 'same');
% calculate q vector q = x .^ 2; q = conv(q, ones(1, w), 'same');
% calculate output values o = (q - s .^ 2 ./ n) ./ (n - 1);
% have to take the square root since output o is the % square of the standard deviation currently o = o .^ 0.5

bilal cheb
bilal cheb 2021 年 6 月 17 日
jhkklh;

Community Treasure Hunt

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

Start Hunting!

Translated by