How to define data array in simulink

조회 수: 109 (최근 30일)
rahut patil
rahut patil 2019년 3월 28일
답변: rahut patil 2019년 5월 9일
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