How can i convert excel file to .mat format and call to matlab code

35 ビュー (過去 30 日間)
NN
NN 2020 年 8 月 21 日
コメント済み: Star Strider 2020 年 8 月 22 日
I have an excel file named DAH,numeric file .How can i call that excel file to matlab code.Should i convert it to .mat format to call?
please find the below code
filename = 'DAH.xlsx';
a = xlsread(filename);
save(matfileName,'a');
x=a(:,1);
plot(x)
i am getting this error
Error using xlsread (line 136)
XLSREAD unable to open file 'DAH.xlsx'.
File 'C:\Users\Neethu Elizabeth\Downloads\DAH.xlsx' not found.
  1 件のコメント
Adam Danz
Adam Danz 2020 年 8 月 22 日
The xlsread function is a bit outdated. Consider replacing it with readtable, readmatrix, or readcell.

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

採用された回答

Star Strider
Star Strider 2020 年 8 月 21 日
Provide the complete file path to ‘DAH.xlsx’ . That is easiest to do with the fullfile function.
  6 件のコメント
NN
NN 2020 年 8 月 22 日
i got it cleared.i have an excel file which has two columns, first column represent time of the dayfrom0.00 and second column represent values with respect to the time of the day.but when i plot the column y axis shows differently, it shows second column values but not exact time as mentioned in the first column .Waht should i do to correct the timing
Star Strider
Star Strider 2020 年 8 月 22 日
I cannot determine that because I do not know what the first column is. I also do not know what version/release of MATLAB you have.
One option, to be safe, is to to use the datenum function to convert the times to date numbers. Those values should plot correctly.
(A better approach would be to use datetime, and perhaps readtable or readmatrix instead of xlsread, however I do not know if you have those options.)

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by