I would like to randomly mixed rows from Excel through MATLAB

1 view (last 30 days)
I am reading data from excel through MATLAB. I would like that each time i run the script , i get my rows to be randoms. But i don't Know how to proceed.
To be more specific, For instance, i would like that when running the script for the first time, my first row could be my 5th row or 15 th row and so on
data = xlsread('excel_data.xlsx');
handles.v_thickness_1 = data(:,1);
handles.v_thickness_2 = data(:,2);
handles.h_thickness_1 = data(:,3);
handles.h_thickness_2 = data(:,4);
handles.v_or_h_array = data(:,6);
handles.exp_counter = 1;
handles.region1 = [];

Accepted Answer

Voss
Voss on 20 Apr 2022
Edited: Voss on 20 Apr 2022
data = xlsread('excel_data.xlsx');
% randomly permute the rows of data:
data = data(randperm(size(data,1)),:);
handles.v_thickness_1 = data(:,1);
handles.v_thickness_2 = data(:,2);
handles.h_thickness_1 = data(:,3);
handles.h_thickness_2 = data(:,4);
handles.v_or_h_array = data(:,6);
handles.exp_counter = 1;
handles.region1 = [];

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!