How to import several input signals from spreadsheet into one inport?
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
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
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Load Signal Data for Simulation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!