フィルターのクリア

Why I got the error "Operator '-' is not supported for operands of type 'struct'."?

55 ビュー (過去 30 日間)
Ryan Scott
Ryan Scott 2020 年 5 月 8 日
回答済み: Sulaymon Eshkabilov 2020 年 5 月 8 日
My code
%Convert from Fahrenheit to Kelvin
TempK = ((X(:,1)-32)*5/9)+273.15;
  6 件のコメント
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2020 年 5 月 8 日
Can you show the content of your imported data (variable) X?

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

採用された回答

Cris LaPierre
Cris LaPierre 2020 年 5 月 8 日
編集済み: Cris LaPierre 2020 年 5 月 8 日
When importing a spreadsheet, importdata returns a scalar structure array (see here). Your error, then, is because you are not accessing the data properly (see examples on the page I linked to).
Is there a reason you are using this import function? I'd suggest using readtable instead. You will have to learn how to access data in a table as well. I'd suggest this short video.

その他の回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2020 年 5 月 8 日
Answer:
X= X.data(:,1);
TempK = ((X1-32)*5/9)+273.15;

カテゴリ

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