MatLab does not reads Excel sheet properly

5 ビュー (過去 30 日間)
MINATI PATRA
MINATI PATRA 2024 年 2 月 12 日
コメント済み: MINATI PATRA 2024 年 2 月 13 日
status = mkdir('D:\PK90'); cd D:\PK90
filename = 'sample111.xlsx'; T = readtable(filename);
P = 2*T.A + 3*T.B + 4*T.C + 5*T.D + 6*T.E
%% When running the Excel sheet, I want MatLab to read the values of all the parameters as varies in the sheet downward. When one parameter varies other values will be considered from first row.
  4 件のコメント
MINATI PATRA
MINATI PATRA 2024 年 2 月 13 日
移動済み: Cris LaPierre 2024 年 2 月 13 日
Sorry for the inconvinience.
Here is the excel sheet attached.
I want to run the code with variations of different parameters BUT when suppose I take values of 'A' as 2, 3 , values of other parameters are the default values (GREEN color, FIRST line values)
MINATI PATRA
MINATI PATRA 2024 年 2 月 13 日
@
Dyuman
The sheet is in C: drive where MatLab is present, then result will be created in D:drive.
Actually this is part of the full code.

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

採用された回答

Cris LaPierre
Cris LaPierre 2024 年 2 月 13 日
移動済み: Cris LaPierre 2024 年 2 月 13 日
readtable just loads the data as is. You will still need to write code to perform any manipulation to the data. Perhaps fillmissing does what you want?
d=readtable("sample111.xlsx")
d = 12×5 table
A B C D E ___ ___ ___ ___ ___ 1 2 0.5 0.1 0.1 2 NaN NaN NaN NaN 3 NaN NaN NaN NaN 1 1 NaN NaN NaN NaN 3 NaN NaN NaN NaN 2 0 NaN NaN NaN NaN 1 NaN NaN NaN NaN 0.5 0.3 NaN NaN NaN NaN 0.5 NaN NaN NaN NaN 0.1 0.3 NaN NaN NaN NaN 0.5 NaN NaN NaN NaN 0.1
% replace NaNs with previous value
d = fillmissing(d,"previous")
d = 12×5 table
A B C D E _ _ ___ ___ ___ 1 2 0.5 0.1 0.1 2 2 0.5 0.1 0.1 3 2 0.5 0.1 0.1 1 1 0.5 0.1 0.1 1 3 0.5 0.1 0.1 1 2 0 0.1 0.1 1 2 1 0.1 0.1 1 2 0.5 0.3 0.1 1 2 0.5 0.5 0.1 1 2 0.5 0.1 0.3 1 2 0.5 0.1 0.5 1 2 0.5 0.1 0.1
  1 件のコメント
MINATI PATRA
MINATI PATRA 2024 年 2 月 13 日
Thanks
Cris LaPierre, it worked.

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

その他の回答 (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