- it saves us from re-creating data to test any code
- it safeguards against your description containing any inaccuracy compared to what you actually have
Operator '>=' is not supported for operands of type 'cell'
5 次查看(过去 30 天)
显示 更早的评论
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});
回答(2 个)
Steven Lord
2021-6-29
T = {[], datetime('tomorrow')}
thor = {datetime('today')}
T{2} <= thor{1} % false
T{2} <= thor(1) % error
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.
Montserrat
2023-6-11
edad = 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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!