Plot from excel sheet to matlab

1,308 ビュー (過去 30 日間)
Hilbrand Swieringa
Hilbrand Swieringa 2015 年 9 月 23 日
Hello everybody,
Yesterday I had the question to get mean gray level value into an excel sheet. After the help I managed to get it work. Now i have the following question.
I can plot in Excel but I know that matlab can do it for me.
I found the following code,
% [num, txt, raw] = xlsread('mean_gray_level_value.xlsx', 1);
% plot(num)
% num = sort(num);
% for i = 1:numel(num)
% NumCell(i) = {num2str(num(i))};
% end
% set(gca,'Xtick',1:numel(num),'XTickLabel',txt, 'Ytick', num,'YTickLabel',NumCell)
Can someone help me to plot from data of an excel sheet? the y axis must be from 0 to 255 the x axis must be the number of the analysis.
I hope you can help me,
Kind regards
  1 件のコメント
OMAR EL MZOURI
OMAR EL MZOURI 2023 年 5 月 24 日
Hello, I need a help for how can I plot a graph from excel data in real time?

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

採用された回答

Jae Song
Jae Song 2015 年 9 月 23 日
You can simply read data in an Excel file using the readtable function.
Then, read the column data as X and Y variables into Matlab. ( Use the column header names in the Excel file to extract values. Please see the example below)
Use the plot function to create a plot.
%: Read the excel file using readtable function
rawTable = readtable('testData.xlsx','Sheet','Sheet1');
x = rawTable.Header1; %: get the excel column, Header1 (header name)
y = rawTable.Header2; %: get the excel column, Header2 (header name)
figure;
plot(x,y);
  3 件のコメント
Markus M.
Markus M. 2022 年 12 月 12 日
This was so helpful, thank you
Clara Casado-Coterillo
Clara Casado-Coterillo 2023 年 9 月 13 日
And if you only need a few cells of the sheet in the Excel, how can you extract them with readtable function?
Former xlsread used the last argument ['B' num2str(i+2) ':C' num2str(i+2)] to tell Matlab to search from cell B3...
THANKS

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import from MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by