How to import several input signals from spreadsheet into one inport?

조회 수: 4 (최근 30일)
Enzo Yacometti
Enzo Yacometti 2024년 2월 7일
답변: Pramil 2024년 2월 27일
Hello, I have an excel file with the first column of time and 30 other columns with signals I want to import to my simulink model. I’m interested in using root level inport but since they are 30 signals I would like to have just one inport that receives them all. They are simple signals of type double. I’ve tried setting the inport block to dimensions = 30 and using the Root Inport Mapper Tool but I’m unable to map the 30 signals into 1 inport (even though the inport has dimension 30)… is there a way to do this?
  댓글 수: 5
Enzo Yacometti
Enzo Yacometti 2024년 2월 7일
편집: Enzo Yacometti 2024년 2월 7일

I want to have a single inport because I have 30 different signals in my Excel file and I don’t want 30 inports. Instead I would like the possibility to map them all to a single inport that comes into my Simulink model as it can be seen in this page (https://it.mathworks.com/help/simulink/ug/load-data-to-root-level-input-ports-1.html) but in that case it’s done with signals defined in matlab:

Refering to your question, I haven’t grouped any signal, I insist my question is about the possibility to do this, not how I am implementing my model.

Selena Mastrodonato
Selena Mastrodonato 2024년 2월 7일
I took for granted that you had 30 different signals, but the example you are showing refers to a multidimensional signal.
In the first case, I remain in the opinion that it is impossible to do this with Root Inport Mapper. I can suggest the 'From Spreadsheet' block and then group the signals so that you have a single inport. But all depends on what you have to do with the signals.

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

답변 (1개)

Pramil
Pramil 2024년 2월 27일
To import the signals through a single “inport” block, you can do the following:
  • Extract the data from the excel sheet by using the readtable” function and then separate it into “t” and “other” signals. (Code for this can be set in the “PreLoadFcn” in “Model Properties ->Callback functions” accessible under “Modelling” tab).
  • Open the parameter window of “inport” block by double clicking it, go to “Signal Attributes” and set the “port dimensions” to 30. (If you are storing the other signals say in a variable “other”, you can specify the “port dimensions” as “size(other,2)” so in future, if you add or delete a column you do not have to manually change the “port dimensions)”.
  • Now open the “Model Settings -> Data Import/Export” and check the input checkbox and enter “[t,other]” as your inputs. This will allow you to input all the signals through a single inport block.
I have attached an example Simulink model and excel sheet which you can refer to for better understanding.

카테고리

Help CenterFile Exchange에서 Load Signal Data for Simulation에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by