Select data from excel sheet from specific row to specific row
조회 수: 6 (최근 30일)
이전 댓글 표시
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
Dyuman Joshi
2023년 8월 1일
"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.
채택된 답변
Voss
2023년 8월 1일
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))
추가 답변 (1개)
dpb
2023년 8월 1일
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
Voss
2023년 8월 1일
The NaN rows reported by readtable are actually rows with chars, which can be seen by using readcell.
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
