フィルターのクリア

Excel sheet mean of the row and plot the graph

3 ビュー (過去 30 日間)
Kristen Chappel
Kristen Chappel 2021 年 5 月 30 日
コメント済み: Scott MacKenzie 2021 年 5 月 31 日
Hi guys,
I have one excel file named as "Kendri" I wanted to do mean value of some of the column as below and plot the graph
Curve 1 :
X value vs Mean value of the (Elex1 Elex2 Elex3)
Curve 2 :
X value vs Mean value of the (John1 John2 John3)
Curve 1 :
X value vs Mean value of the (Henry1 Henry2 Henry3)
here mean value means, for example :- (Elex1 Elex2 Elex3)/3, also this mean sometimes shows the NAN value in the ouput, how can be the NAN output removed?
is it possible to do it through matlab ? you can see excel file in the question. Also i wanted to draw plot similar like attached picture.
Thanks a ton

採用された回答

Scott MacKenzie
Scott MacKenzie 2021 年 5 月 30 日
編集済み: Scott MacKenzie 2021 年 5 月 30 日
T = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/635705/Kendri.xlsx');
x = T{:,1}; % x-axis conditions
y1 = mean(T{:,2:4}, 2); % Elex
y2 = mean(T{:,5:7}, 2); % John
y3 = mean(T{:,8:10}, 2); % Henry
plot(x, y1);
hold on;
plot(x, y2);
plot(x, y3);
labels = {'Elex', 'John', 'Henry' };
legend(labels);
It appears all the data are positive except for the values in the first and last rows. You can remove these values, if you wish, by changing
x = T{:,1}; % x-axis conditions
y1 = mean(T{:,2:4}, 2); % Elex
y2 = mean(T{:,5:7}, 2); % John
y3 = mean(T{:,8:10}, 2); % Henry
to
x = T{2:end-1,1}; % x-axis conditions
y1 = mean(T{2:end-1,2:4}, 2); % Elex
y2 = mean(T{2:end-1,5:7}, 2); % John
y3 = mean(T{2:end-1,8:10}, 2); % Henry
There are no NaN values in your spreadsheet.
  2 件のコメント
Kristen Chappel
Kristen Chappel 2021 年 5 月 31 日
編集済み: Kristen Chappel 2021 年 5 月 31 日
Thank u, @Scott MacKenzie. What if value is NAN then what should i change in the code? Also if some datas available in the same file but sheet 1, 2 , 3 then how to take that variable in the code. Just example you can see in the below attached excel file
Thanks a lot
Scott MacKenzie
Scott MacKenzie 2021 年 5 月 31 日
If the data include NaN values, just use the omitnan option in the mean function. See Walter's comment.
The readtable function allows you to specify the sheet where the data are located. To read data from sheet 2, use
T = readtable( . . . , 'sheet', 2)
Good luck

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by