2
votes

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...?

1
Your question/sample data are a little confusing. Do you have one signal that takes on different values at t=0.2, then another value at t=0.4, then another at t=0.6 etc., or do you have a block (say a constant) that needs to have a value of 1000 for one complete simulation run (over a specified period of time, and generating potentially multiple output data), then a value of 1500 for another complete simulation run, then 800 for yet another run, etc.Phil Goddard
Ya I have a block that have value of 1000 for one complete simulation and 1500 for another complete simulation,each running for a specified period of time.Santosh

1 Answers

1
votes

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