Select data from excel sheet from specific row to specific row
4 views (last 30 days)
Show older comments
Hi,
I have excel sheet with 8 columns and a lot of rows that are divided into cycles.

I need to make a chart that contains values of all rows that are between values 1...100Cykle. It should looks like below:

Is it possible to load to matlab values from specific row to another row to make chart from them?
2 Comments
Dyuman Joshi
on 1 Aug 2023
"Is it possible to load to matlab values from specific row to another row to make chart from them?"
Yes.
Though I don't understand what exactly the Cykle in your data is.
Can you attach your data (the excel file)? Use the paperclip button to do so.
Accepted Answer
Voss
on 1 Aug 2023
Here is one way to read that file and break its contents up by cykle:
C = readcell('prow_KL_1.xlsx');
idx = find(cellfun(@ischar,C(:,1)));
start_rows = idx(~cellfun(@isempty,regexp(C(idx,1),'\[\d+Cykle\]','once')));
end_rows = [start_rows(2:end); size(C,1)+1];
N_cykles = numel(start_rows);
data = cell(1,N_cykles);
for ii = 1:N_cykles
C_section = C(start_rows(ii)+1:end_rows(ii)-1,:);
C_section(~cellfun(@isnumeric,C_section(:,1)),:) = [];
data{ii} = cell2mat(C_section);
end
disp(data)
data is a cell array containing a matrix of data for each cykle.
Now you can plot whatever you want, e.g.:
figure
hold on
plot(data{1}(:,1),data{1}(:,2))
plot(data{2}(:,1),data{2}(:,2))
plot(data{3}(:,1),data{3}(:,2))
legend("Cykle "+(1:3))
More Answers (1)
dpb
on 1 Aug 2023
It's possible to specify rows to load by address,but NOT by cell content.
You read the full file and then select the data desired by processing the content. In your case you'll have the first task to extract the numeric value of the first column and then find which row contains the range of interest...you may find something like
t=readtable('yourfile');
n=str2num(extract(t.Column1,digitsPattern));
a useful start; you can then locate which are within the desired bounds with a numeric comparison instead of text and locate those values in the file from which to select (it appears) the rows 1 after:1 before the succeeding value as containing the data of interest.
Attaching an actual (smallish) file would let folks illustrate more easily...
4 Comments
Voss
on 1 Aug 2023
The NaN rows reported by readtable are actually rows with chars, which can be seen by using readcell.
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!