How can I import input data from Excel sheet into signal builder programmatically ?
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, I am trying to import input data specified in MS Excel sheet to the signal builder block in Simulink model programmatically. I am able to perform it manually, but unable to do so using Matlab script. Any insight is appreciated.
Respuestas (1)
Shlok
el 4 de Dic. de 2024
Hi Anjali,
To import the data from the excel file into the “Signal Builder” block, follow the following steps:
- First read the XLSX file using “readtable” function and extract the signal and time data. In the following example, I have assumed a sample dataset “dummySignalData.xlsx” with columns "Time" and "Signal".
filepath = 'dummySignalData.xlsx';
data = readtable(filepath);
time = data{:, 'Time'}; % Time vector
signal = data{:, 'Signal'}; % Signal data
- Now open the simulink model consisting of “Signal Builder” block and set the signal data in this block. This can be done using “signalbuilder(block, 'set', signal, group, time, data)” which sets the time and data values for the specified signal(s) and group(s).
model = 'myModel'; % Example model
open_system(model);
block = [model '/mySignalBuilder']; % Assuming the "Signal Builder" block is named "mySignalBuilder" in "sampleModel"
signalbuilder(block, 'set', 'Signal 1', 'Group 1', time, {signal}); % Assuming signal is set for Signal 1 in Group 1
Therefore, using the above approach, we can import the data from the XLSX file to “Signal Builder" block programmatically.
To know more about “signalbuilder” function, refer to the documentation by running the following command:
web(fullfile(docroot, 'simulink/slref/signalbuilder_cmd.html'));
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!