How do I read in data from a spreadsheet to a Test Vector for a SystemTest of a Simulink Model, as datatype single?
1 次查看(过去 30 天)
显示 更早的评论
I have the following error message, listing the source as "Simulink", in the Run Status box of SystemTest:
"Invalid data type for root level inport 'LimitSignal/Signal'. The model is configured to load its root level inports from the workspace. These external inputs must have data type 'double'. This data type does not agree with the data type, 'single', that is being set for this root level inport. Loading external inputs from the workspace is turned off by going to the Simulation menu and selecting Configuration Parameters. On the Data Import/Export page, locate the Load from workspace group and uncheck the Input checkbox."
The recommendation it gives does not work, as that checkbox is already unchecked.
Changing the Simulink model inputs to receive 'double' instead of 'single' prevents this error message, but can't I read in from the spreadsheet as 'single'?
0 个评论
采纳的回答
Fangjun Jiang
2011-8-22
You are using the SystemTest toolbox. It has some type of automation that can import data from Excel sheet behind the scene. I don't know how to resolve that problem. Maybe you can contact TMW tech support for help.
Without the toolbox, normally you would import the data into workspace and then use it in Simulink. It's easy to do the convertion in MATLAB.
Data=xlsread(ExcelFile);
Data=single(Data);
There got be some script that does the import so if you can find it, you can add the single() conversion. Again, calling TWM might be the easiest way to find it out.
5 个评论
Fangjun Jiang
2011-8-22
Good! One more thing to recommend is to do xlsread() once because running it multiple times is in-efficient. Once the data is read in, you can use MATLAB operation to split data into the variable names you want.
data=xlsread('test.xls');
time=single(data(1:21,1));
signal=single(data(1:21,2));
...
更多回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!