Como Importar Datos En Matlab De Excel
INTRODUCTION It is important to be able to import and export data to and from Excel in order to compare analytical and experimentalresults. This tutorial will address this issue and discuss methods to do this using Simulink and the MATLAB command window. EXPORTING DATA TO EXCEL To illustrate how this is done, we will use thefollowing example: Create a simple Simulink Model with Sine Wave, Scope, and To Workspace blocks as in Fig. 1.
Fig. 1. Simple sine wave model
Open the To Workspace block and in the Variable Name field,type in "y" (no quotes) or whatever name you wish to use for the output variable. Now select Array from the pull down menu. Leave the default values for the remaining fields. The To Workspace blockwill allow you to transfer data from the Simulink model to the MATLAB workspace, where you can further manipulate the data for export to Excel. When you run the simulation for the model above, MATLABwill create an output array assigned to the variable y and a time array assigned to the default variable tout. You then want to create a matrix combining these two arrays. Once this has been done, onesimple command will create an Excel file. After you have run the simulation, go to the MATLAB workspace. At the command prompt type in the following commands: >>A = [tout, y]; >>save filename.xls A–ascii You should now have a file named filename.xls in your current working directory. Open Excel and choose File, Open, go to your working directory and select filename.xls, Open, and a window willappear as in Fig. 2.
Importing and Exporting Data from MATLAB and Simulink to Excel
Rev 021704 1
Fig. 2. Specification of fixed width for MATLAB data import.
Choose
Fixed width, Next, anda new window will appear as in Fig. 3.
Fig. 3. Specification of column break for MATLAB data import.
Follow the instructions in the window to set the column break, and select Next, Finish....
Regístrate para leer el documento completo.