Assign fields to structure array in Simulink

I have an Array of 5 structures, say A(1), A(2)...A(5). Each of them have 3 fields which are: A(i).field1, A(i).field2, A(i).field3.
I would like to assign a constant value to each field in all structure using Simulink blocks. I am using for loop to circle amongst A(i). How can I access field1, field2, field3 in each structure?

 채택된 답변

stozaki
stozaki 2020년 3월 3일

0 개 추천

You can use MATLAB Function as following.
I attached example model and .mat included struct data.

댓글 수: 2

VuKhoa
VuKhoa 2020년 3월 5일
Thank you! Is it impossible to create a structure without a .mat file?
@VuKhoa,
You need a .mat file.
If you can use the bus signal, you can use a method like the attachment.
The method is to assign structure variables to bus signals.
run myData
run myBus
open_system('BusModel');
sim('BusModel');
Regards,
stozaki

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Modeling에 대해 자세히 알아보기

제품

질문:

2020년 3월 2일

댓글:

2020년 3월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by