Reputation: 1839
In the simulink I have a short transmission line model. Now I want the data of the load be imported from excel file.
But in the help section of matlab, they state that the file must be in form of
TIME DATA
0.2 1000
0.4 1500
0.6 800
And use of xlsread() function.I did that and got the data in matrix form.
But I want that the simulink should get data 1000, simulate it, output the result and then get data 1500 and again simulate ...so on and so forth. I am doing this because the data is of 100 rows, and it is humanly impossible and boring to every time change the value of a block in simulink.
So is it possible to import one data set, simulate it, o/p its results(maybe in excel file), and then take another data set and again simulate it...?
Upvotes: 2
Views: 1659
Reputation: 10772
You should set your model up so that all parameters (or at a minimum all parameters that need to change from one simulation run to the next) are the name of a MATLAB variable. When you start the simulation the model will look in the MATLAB Workspace for the value of the variable with that name, and that value will be used in the simulation.
Prior to running your simulation you should use the function xlsread (in MATLAB) to load your Excel data into the MATLAB Workspace (it sounds like you have done this). Then you should split that data out to create appropriate variables in the MATLAB Workspace that correspond to the variables that you have used in your model (it sounds like you haven't done this).
Assuming you have used xlsread successfully and created the matrix
myData = [0.2 1000; 0.4 1500;0.6 800];
Then you want something like
for idx = 1:size(myData,1)
myRequiredParameter = myData(idx,2); % Use this variable as a parameter in your model
mySimulationResults = sim('MyModelName'); % run the simulation
% Post process the results
end
Upvotes: 1