Select data from excel sheet from specific row to specific row

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

"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.

댓글을 달려면 로그인하십시오.

 채택된 답변

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)
Columns 1 through 11 {737×7 double} {706×7 double} {713×7 double} {709×7 double} {701×7 double} {706×7 double} {705×7 double} {698×7 double} {699×7 double} {692×7 double} {706×7 double} Columns 12 through 22 {700×7 double} {697×7 double} {703×7 double} {699×7 double} {701×7 double} {705×7 double} {692×7 double} {696×7 double} {681×7 double} {696×7 double} {694×7 double} Columns 23 through 33 {699×7 double} {699×7 double} {694×7 double} {695×7 double} {698×7 double} {692×7 double} {702×7 double} {682×7 double} {689×7 double} {698×7 double} {697×7 double} Columns 34 through 44 {692×7 double} {697×7 double} {692×7 double} {705×7 double} {698×7 double} {693×7 double} {698×7 double} {698×7 double} {698×7 double} {699×7 double} {691×7 double} Columns 45 through 55 {691×7 double} {695×7 double} {700×7 double} {687×7 double} {695×7 double} {684×7 double} {691×7 double} {688×7 double} {692×7 double} {687×7 double} {690×7 double} Columns 56 through 66 {693×7 double} {694×7 double} {692×7 double} {690×7 double} {693×7 double} {689×7 double} {693×7 double} {693×7 double} {699×7 double} {692×7 double} {691×7 double} Columns 67 through 77 {687×7 double} {692×7 double} {695×7 double} {690×7 double} {695×7 double} {691×7 double} {691×7 double} {698×7 double} {697×7 double} {693×7 double} {694×7 double} Columns 78 through 88 {693×7 double} {691×7 double} {684×7 double} {689×7 double} {693×7 double} {697×7 double} {690×7 double} {691×7 double} {681×7 double} {698×7 double} {689×7 double} Columns 89 through 99 {678×7 double} {687×7 double} {689×7 double} {694×7 double} {688×7 double} {685×7 double} {702×7 double} {690×7 double} {688×7 double} {693×7 double} {683×7 double} Column 100 {696×7 double}
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
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

ok so i will try to select data when it will be loaded to matlab. I have uploaded the file above.
tT=readtable('prow_KL_1.xlsx');
head(tT)
Column1 Column2 Column3 Column5 Column6 Column7 Column8 _______ _______ __________ _______ __________ __________ __________ 0 33564 0 33564 0 0 0 0.0025 33577 5.3778e-07 33577 5.3778e-07 5.3778e-07 5.3778e-07 0.01 33589 2.6406e-06 33589 2.6406e-06 2.6406e-06 2.6406e-06 0.0225 33665 6.1669e-06 33665 6.1669e-06 6.1669e-06 6.1669e-06 0.04 33777 1.1e-05 33777 1.1e-05 1.1e-05 1.1e-05 0.0625 33882 1.7222e-05 33882 1.7222e-05 1.7222e-05 1.7222e-05 0.09 33951 2.4585e-05 33951 2.4585e-05 2.4585e-05 2.4585e-05 0.1225 34025 3.3254e-05 34025 3.3254e-05 3.3254e-05 3.3254e-05
No sign of the cycle indicator in that file????
tT(740:750,:)
ans = 11×7 table
Column1 Column2 Column3 Column5 Column6 Column7 Column8 _______ __________ _________ __________ _________ _________ _________ NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 1357.2 62898 0.0025874 62898 0.0025874 0.0025874 0.0025874 1357.9 62899 0.0025908 62899 0.0025908 0.0025908 0.0025908 1361.6 63036 0.0029539 63036 0.0029539 0.0029539 0.0029539 1365.3 63491 0.0040143 63491 0.0040143 0.0040143 0.0040143 1369 66943 0.0060541 66943 0.0060541 0.0060541 0.0060541 1372.7 88862 0.0084625 88862 0.0084625 0.0084625 0.0084625 1376.4 1.4262e+05 0.010571 1.4262e+05 0.010571 0.010571 0.010571 1380.1 2.2123e+05 0.012462 2.2123e+05 0.012462 0.012462 0.012462 1383.8 3.0596e+05 0.014512 3.0596e+05 0.014512 0.014512 0.014512
Well that has some NaN at the locations shown in the original; is that some sort of klew, mayhaps? What's just ahead of this???
tT(735:745,:)
ans = 11×7 table
Column1 Column2 Column3 Column5 Column6 Column7 Column8 _______ _______ _________ _______ _________ _________ _________ 1346.9 63057 0.0026061 63057 0.0026061 0.0026061 0.0026061 1350.6 63046 0.0025985 63046 0.0025985 0.0025985 0.0025985 1354.2 62974 0.0025917 62974 0.0025917 0.0025917 0.0025917 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 1357.2 62898 0.0025874 62898 0.0025874 0.0025874 0.0025874 1357.9 62899 0.0025908 62899 0.0025908 0.0025908 0.0025908 1361.6 63036 0.0029539 63036 0.0029539 0.0029539 0.0029539 1365.3 63491 0.0040143 63491 0.0040143 0.0040143 0.0040143
Well, there's a section between some numeric values, but it's too much to expect us to ferret out what it is that's here and how if relates to the original question/fiile...
This is file have been downloaded from measuring device so there can be some errors and NaN values
The NaN rows reported by readtable are actually rows with chars, which can be seen by using readcell.

댓글을 달려면 로그인하십시오.

카테고리

제품

질문:

2023년 8월 1일

댓글:

2023년 8월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by