MatLab does not reads Excel sheet properly

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 comentarios

Cris LaPierre
Cris LaPierre el 12 de Feb. de 2024
Please attach your excel sheet using the paperclip icon in the ribbon.
Dyuman Joshi
Dyuman Joshi el 12 de Feb. de 2024
Just to clarify - You are making a new directory (which will be an empty folder) and then assign it to be the current directory (again empty), from which you are trying to read a file (which does not exist in that empty folder)?
MINATI PATRA
MINATI PATRA el 13 de Feb. de 2024
Movida: Cris LaPierre el 13 de Feb. de 2024
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 el 13 de Feb. de 2024
@
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.

Iniciar sesión para comentar.

 Respuesta aceptada

Cris LaPierre
Cris LaPierre el 13 de Feb. de 2024
Movida: Cris LaPierre el 13 de Feb. de 2024
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

Más respuestas (0)

Etiquetas

Preguntada:

el 12 de Feb. de 2024

Comentada:

el 13 de Feb. de 2024

Community Treasure Hunt

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

Start Hunting!

Translated by