MatLab does not reads Excel sheet properly

1 次查看(过去 30 天)
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

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by