Operator '>=' is not supported for operands of type 'cell'

조회 수: 8 (최근 30일)
Riccardo Tronconi
Riccardo Tronconi 2021년 6월 29일
댓글: Walter Roberson 2023년 6월 12일
Hi guys I have a problem in comparing two cells.
My input cells are T{n}, where n=3
  • T{1} [mx4]
  • T{2} [nx4]
  • T {3} [k x 4]
and thor cell [sx1] (Data tipe is a datetime)
To simplify I m looking for all index of T{2} that verify the following in which I am comparing datetimes:
find((T{2}(1:end,1))>= thor(1,1) & (T{2}(1:end,1))< thor(2,1));
The problem is the operator but I guess is "1:end" because the following code worked properly..
find(T{2}{2,1}>= thor{2,1} & T{2}{2,1}< thor{3,1});
  댓글 수: 5
Riccardo Tronconi
Riccardo Tronconi 2021년 6월 30일
For both of them?
Stephen23
Stephen23 2021년 6월 30일
S1 = load('thor.mat') % okay
S1 = struct with fields:
thor: {537×1 cell}
S2 = load('T.mat') % corrupt
Error using load
Unable to read MAT-file /users/mss.system.YD2TnT/T.mat. File might be corrupt.

댓글을 달려면 로그인하십시오.

답변 (2개)

Steven Lord
Steven Lord 2021년 6월 29일
T = {[], datetime('tomorrow')}
T = 1×2 cell array
{0×0 double} {[30-Jun-2021]}
thor = {datetime('today')}
thor = 1×1 cell array
{[29-Jun-2021]}
T{2} <= thor{1} % false
ans = logical
0
T{2} <= thor(1) % error
Comparison is not defined between datetime and cell arrays.
The next-to-last line indexes into thor using curly braces to extract the contents of the first cell, the last line indexes into thor using parentheses to extract the first cell.
  댓글 수: 1
Riccardo Tronconi
Riccardo Tronconi 2021년 6월 29일
It does not work either. My T{2} in not a value but an array mx4

댓글을 달려면 로그인하십시오.


Montserrat
Montserrat 2023년 6월 11일
edad = x.age;
Unable to resolve the name 'x.age'.
H = x.sex == "female";
M = x.sex == "male";
idx = x.localization;
% Filtrar los datos por sexo y calcular los conteos de edades
femaleCounts = countcats(categorical(edad(H & idx)));
maleCounts = countcats(categorical(edad(M & idx)));
% Obtener las categorías de edad y ordenarlas de forma ascendente
ageCategories = categories(categorical(edad));
ageCategories = sort(ageCategories);
% Crear el gráfico de barras apiladas
figure;
bar([femaleCounts maleCounts], 'stacked');
legend('Mujeres', 'Hombres');
xticks(1:length(ageCategories));
xticklabels(ageCategories);
xlabel('Edad');
ylabel('Cantidad');
title('Análisis de Edades en Hombres y Mujeres con Cáncer');
% Ajustar el tamaño de la figura
fig = gcf;
fig.Position(3:4) = [800 500];
  댓글 수: 1
Walter Roberson
Walter Roberson 2023년 6월 12일
I do not understand how this solves the user's difficulty?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by