- Read Excel Data: Use the MATLAB Function block to read the Excel file and extract the load power data. We can use the “readtable” function to read the data from the Excel file.
- Interpolate Data: Since the data is provided at second intervals, We can interpolate the data to get load power values for each simulation time step. MATLAB provides functions like “interp1” for interpolation.
- Output Load Power: Output the interpolated load power values from the MATLAB Function block.
- Sample Time: Set the sample time of the MATLAB Function block to match your simulation time step (e.g., 1 second).
- Simulate: Run your simulation, and the load power values will change every second based on the data from the Excel file.
How can I use a variable load power in my simulink which is changing every second?
19 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello everyone,
I am using a daily power consumption of a house in my model in simulink, which is an excel file with 2 Columns. the 1st one is for seconds and the 2nd one is for the value of the power at this time.
I am trying to use it in my simulink but I always get an error because the active load power can not be changed while the simulation is running.
so How can I make my power changes every second in my simulation scope while my model is running?
I have used a variable resistor but it didn not work.
Thanks in advance.
0 Kommentare
Antworten (1)
Anurag Ojha
am 8 Aug. 2023
Hello Omar,
As per my understanding you're trying to simulate a dynamic variable load power profile in Simulink based on the data from an Excel file. You're correct that we cannot directly change simulation parameters, such as load power, while the simulation is running. However, there are ways to achieve your goal. Here's one workaround:
Using a MATLAB Function Block:
We can use a MATLAB Function block in Simulink to read the Excel file and provide the changing load power values to simulation.
You can follow these steps:
Take care of the cases where the simulation time exceeds the range of your Excel data. Here's a example of what the MATLAB Function block code might look like:
function loadPower = fcn(time)
% Load data from Excel file
excelData = readtable('power_data.xlsx');
% Extract time and load power columns
excelTime = excelData(:, 1);
powerValues = excelData(:, 2);
% Interpolate load power values
loadPower = interp1(excelTime, powerValues, time, 'linear', 'extrap');
end
You can refer to following MATLAB documentation to explore more:
Hope it helps!
0 Kommentare
Communitys
Weitere Antworten in Power Electronics Control
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!