Hello. May I know how do we insert equation in MATLAB Function

I am new to MATHLAB Simulink so I do not know how to code the MATLAB Function. Is what I do correct or wrong. I wanted to insert equation in the MATHLAB Function. Thank you so much for your help. Really apreciate it.

 采纳的回答

MATLAB uses () for indexing. So u(1) not u[1]
I cannot read what is on line 3. It sort of looks like it might be
y = t;
if so it would be a problem because t is not defined.
The y that is being calculated on line 2 is a scalar, and it not obvious why you would want to transform it on line 3... it might be more clear if we could read the line.

3 个评论

Hello sir thank you for the reply. Sorry for the inconvenience. Here is the full screenshot.
your u appears to have at least two elements. When you assign y=u then all of the elements are copied to y. Because that is the first assignment to the variable, Simulink understands that you are doing that assignment in order to set the size and datatype of y.
Then after that you assign a scalar to the y that you just told Simulink is the same size as u.
You attempt to use [] for indexing but MATLAB and Simulink never use [] for indexing. As I indicated earlier use u(1) not u[1]

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Matrix Indexing 的更多信息

产品

版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by