I have an m file creating MTPA (Maximum Torque Per Ampere) curve. In simulink model I have a constantly changing input that needs to select the data according to the curve. But I haven't seen any possible way to do this, please help me...

 採用された回答

Mischa Kim
Mischa Kim 2014 年 3 月 21 日

0 投票

Sreerag, have you looked into lookup tables?

4 件のコメント

Sreerag Kunnathu Sugathan
Sreerag Kunnathu Sugathan 2014 年 3 月 21 日
I have. But the problem is I haven't seen any way to incorporate the m file into the look up table. I am new to this, so please help me out
Mischa Kim
Mischa Kim 2014 年 3 月 21 日
Of course, if you already have an m-file that creates the curve (and if that's all you need) you can use the function itself as the lookup table. From the Simulink library "User-Defined Functions" pick a MATLAB function block (in earlier MATLAB releases the block used to be called Embedded MATLAB function), open it and insert the MATLAB code. E.g.
function out = myLookup(in)
out = sin(in);
end
Sreerag Kunnathu Sugathan
Sreerag Kunnathu Sugathan 2014 年 3 月 21 日
But still there is a problem. I have the m file that creates the curve. I need to get the y axis data from the curve as output with respect to the input data. Is that possible??
Mischa Kim
Mischa Kim 2014 年 3 月 21 日
編集済み: Mischa Kim 2014 年 3 月 21 日
Sure, see the example above. in would be your input value ( x ), the sine is the curve (replace with your curve), out is the corresponding output value ( y ). For each input value you get one corresponding output value, continuously changing the input will result in the corresponding output signal based on the curve.
And, of course, the curve does not need to be a nice, smooth one, as the sine above. That is, you can also, e.g., if-else or switch commands to construct the curve.

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

その他の回答 (1 件)

zhenyu jia
zhenyu jia 2017 年 6 月 7 日

0 投票

hello, could you send me the m file? thank you very much!

カテゴリ

ヘルプ センター および File ExchangeEvent Functions についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by