How to define data array in simulink

90 次查看(过去 30 天)
Hello all,
I want to define the array in simulink which consist of 'n' elements in it.
Can I read and write the array elements individually? If yes. How.?
please tell me as early as possible.
Thanks and Regards,
Rahut Patil.
  2 个评论
madhan ravi
madhan ravi 2019-3-28
Use constant block, what do you mean by read and write the array individually?
rahut patil
rahut patil 2019-3-28
how can I use the conststant block?
Write : I will write the values of array elements in running mode.
read :I will read the values of array elements in running mode.
Thanks and Regards,
Rahut Patil.

请先登录,再进行评论。

回答(3 个)

madhan ravi
madhan ravi 2019-3-28
Screen Shot 2019-03-28 at 4.26.17 PM.png
Screen Shot 2019-03-28 at 4.26.28 PM.png
  2 个评论
rahut patil
rahut patil 2019-3-28
编辑:madhan ravi 2019-3-28
Hello Madhan,
I tried but it is giving the following error when I import the vector from workspace. I tried by changing the data types and sample time -1 to 0 and vice versa. But it is giving same error.
=== Simulation (Elapsed: 0.325 sec) ===
Error:Unsupported input format for From Workspace block 'Array/From Workspace'. Available formats are double non-complex matrix, a structure with or without time, or a structure with MATLAB timeseries as leaf nodes. All formats require the data to be finite (not Inf or NaN).
Thanks Regards,
Rahut Patil.
madhan ravi
madhan ravi 2019-3-28
编辑:madhan ravi 2019-3-28
Share the picture of your model/upload your model by clicking the paper clip button.

请先登录,再进行评论。


rahut patil
rahut patil 2019-3-28
Plese find the attached model.
Thanks and Regards,
Rahut Patil.
  2 个评论
rahut patil
rahut patil 2019-3-28
Hi Madhan,
I got the solution. I need to run the array in the command window. But want to assign a value to the perticular array element in the running mode. Can it be possible in simulink? Please suggest.
Thanks Regards,
Rahut Patil.
madhan ravi
madhan ravi 2019-3-28
Screen Shot 2019-03-28 at 7.01.25 PM.png
% MATLAB Function code
function y = fcn(u,index_number,value_assigned)
y = u;
y(index_number) = value_assigned;

请先登录,再进行评论。


rahut patil
rahut patil 2019-5-9
Hi Madhan,
Sorry for late reply. Thank you so much. It is working. Thank you for the support.
Best Regards,
Rawootray Patil.

类别

Help CenterFile Exchange 中查找有关 Subsystems 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by