Here you are an example of what I would like to perform
- Run CreateSimSig.m
- Run TestDSM_RW.slx
Then take a look in the Matlab function, it's what I would like to perform...
Here the code:
function updateAndReadDSMValues(file_path)
% Load data from the Excel file
data = xlsread(file_path);
% Get the list of DSMs in the Simulink model
dsm_list = find_system(gcs, 'SearchDepth', 1, 'BlockType', 'DataStoreMemory');
% Iterate through each row in the Excel file
for i = 1:size(data, 1)
% Get the variable name and its value from the Excel file
variable_name = data(i, 2);
variable_value = data(i, 3);
% Check if the variable name corresponds to a DSM in the model
if ismember(variable_name, dsm_list)
% Update the value of the DSM with the new value
set_param(variable_name, 'Value', num2str(variable_value));
disp(['The value of DSM "', variable_name, '" has been updated to ', num2str(variable_value)]);
% Introduce a delay of 50 ms
pause(0.05);
% Read the value of the variable in column 4
variable_to_read = data(i, 4);
read_value = evalin('base', variable_to_read);
% Write the read value to column 6
data(i, 6) = read_value;
else
disp(['No DSM corresponding to the variable name "', variable_name, '" found in the model.']);
end
end
% Save the updated data back to the Excel file
xlswrite(file_path, data);
end