Subsetting works in mlx file but not m file

조회 수: 1 (최근 30일)
Metin Akyol
Metin Akyol 2022년 2월 3일
답변: Prateekshya 2023년 9월 29일
The following line works without any issues in an mlx file but not in an m file for some reason. Does anyone know why?
subset_table = table_1(table_1.Date == datetime('01/27/2022','InputFormat','MM/dd/uuuu'),:);
In the mlx file it works for some reason but in the m file I am getting this error:
Operator '==' is not supported for operands of type 'cell'

답변 (1개)

Prateekshya
Prateekshya 2023년 9월 29일
Hi Metin,
As per my understanding you are getting inconsistent results acorss MATLAB scripts (.m) and live scripts (.mlx). The following code works perfectly fine in both the cases i.e., scripts and live scripts.
d = today("datetime")
subset_table = d == datetime('01/27/2022','InputFormat','MM/dd/uuuu')
Hence it turns out that the "table_1" variable is of type "cell". You can use "cell2table" for converting it to table format. For more information you can follow this link: https://in.mathworks.com/help/matlab/ref/cell2table.html
I hope it helps!

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by