Hi Ahmed,
I understand you want to map your data based on sectors.
To map the output of your code (i.e., E25-50, H25-50, and CCS25-50) into their respective columns in a new Excel file ('Mapping'), you'll need to follow a series of steps.
- Read the 'Mapping' Excel File
[~, ~, mapping] = xlsread('Mapping.xlsx');
2. Create a Function to Map Values: You can use the below function for refrence.
function updatedMapping = mapValues(mapping, data, columnIndex)
% Assuming mapping is the content of the 'Mapping' Excel file
% data is one of your arrays like E25, H25, etc.
% columnIndex is the column in 'mapping' where the data should go
% Iterate through each row in the data array
for i = 1:size(data, 1)
sector = data{i, 1}; % The sector name
value = data{i, 2}; % The value to map
% Find the matching row in the mapping array
rowIndex = find(strcmp(mapping(:, 1), sector));
if ~isempty(rowIndex)
% If a matching row is found, update the mapping array
mapping{rowIndex, columnIndex} = value;
end
end
updatedMapping = mapping;
end
3. Apply the Mapping Function for Each Dataset
% Example usage for E25, assuming E25 values go in column 2
mapping = mapValues(mapping, E25, 2);
% Repeat for H25, CCS25, etc., with the correct column indices
mapping = mapValues(mapping, H25, 3);
mapping = mapValues(mapping, CCS25, 4);
4. Write the Updated Mapping Back to an Excel File
xlswrite('UpdatedMapping.xlsx', mapping);
I hope it helps!