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

4 Ansichten (letzte 30 Tage)
Enzo Yacometti
Enzo Yacometti am 7 Feb. 2024
Beantwortet: Pramil am 27 Feb. 2024
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 Kommentare
Enzo Yacometti
Enzo Yacometti am 7 Feb. 2024
Bearbeitet: Enzo Yacometti am 7 Feb. 2024

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 am 7 Feb. 2024
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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Pramil
Pramil am 27 Feb. 2024
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.

Kategorien

Mehr zu Load Signal Data for Simulation finden Sie in Help Center und File Exchange

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by