- Convert strings to numerical values: If your strings can be represented as numerical values, you can convert them to numbers in Excel before importing the data into Simulink. For example, you can assign unique numerical values to each string and use those values in Simulink.
- Use a MATLAB Function block: Instead of using the From Spreadsheet block directly, you can try using a MATLAB Function block to read the data from the spreadsheet. Inside the MATLAB Function block, you can use MATLAB's built-in functions like xlsread or readtable to read the data from the Excel file, including strings and arrays with corresponding time values.
- Export as CSV: If the Excel spreadsheet contains only strings and arrays with corresponding time values, you can save it as a CSV (Comma-Separated Values) file. Simulink has a block called From Workspace that can read data from a CSV file. You can then use this block to import the data into your simulation.
String and array input from xlsx file
11 views (last 30 days)
Show older comments
Looking to directly input strings and arrays with corresponding time values for simulation from an excel spreadsheet. From what I can tell, the From Spreadsheet block only has the capability to take numerical data from spreadsheets. Is there a work around with the From Spreadsheet block or using another block that anyone is aware of? I've played around with using a matlab function to achieve such behavior, but no luck. Thanks in advance.
0 Comments
Answers (1)
Abhishek Krishna
on 3 Jul 2023
Hi,
Yes, you are right that the From Spreadsheet block in Simulink typically deals with numerical data. However, there are a few workarounds you can try to input strings and arrays with corresponding time values from an Excel spreadsheet.
Remember to ensure that the file path is correctly specified, and that the data is formatted appropriately for the method you choose.
I hope this helps!
0 Comments
See Also
Categories
Find more on Sources in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!