open the .mat-file with the name of 'priceenergy2020', search in each column the lowest value in matlab

main.m
% Load the .mat file
data = load('priceenergy2020.mat');

% Get the field names of the loaded data
fieldNames = fieldnames(data);

% Initialize variables to store the lowest value and its column index
minValue = inf;
minIdx = 0;

% Loop through each field (assuming columns are stored as fields)
for i = 1:numel(fieldNames)
    columnData = data.(fieldNames{i});
    [minVal, idx] = min(columnData);
    
    % Check and update the lowest value and index
    if minVal < minValue
        minValue = minVal;
        minIdx = i;
    end
end

% Display the lowest value and its column index
fprintf('Lowest value found: %f\n', minValue);
fprintf('Found in column: %s\n', fieldNames{minIdx});
689 chars
26 lines

gistlibby LogSnag