Dot indexing is not supported for variables of this type
Show older comments
I am not able to understand why this error occurs. Could any one please correct me here. [Kindly look for indicated line where error occured].
age_ranges = [20 30;31 40;41 50;51 60;61 70]; % Modify as needed
age_labels = {'20-30 years','31-40 years','41-50 years','51-60 years','61-70 years'}; % Labels for age ranges
% Create a cell array to store subsets of data based on age ranges
age_groups = cell(size(age_ranges, 1), 1);
% Separate data based on age ranges
for i = 1:size(age_ranges, 1)
% Create logical index for this age range
age_min = age_ranges(i, 1);
age_max = age_ranges(i, 2);
age_idx = data_all_MDV0.AGE >= age_min & data_all_MDV0.AGE <= age_max;
end
% Create subplots for each age group
num_groups = length(age_groups);
figure(3);
for i = 1:num_groups
% Get the subset for this age range
age_data = age_groups{i};
% Number of unique time points
unique_times = unique(age_data.TIME); % !!!!!!!!!!!!!! ERROR !!!!!!!!!!!!!!!!!!
% Initialize arrays to store mean and 95th percentile
med_values = zeros(size(unique_times));
percentile_2_5 = zeros(size(unique_times));
percentile_97_5=zeros(size(unique_times));
% Loop over each time point to calculate median and 95th percentile
for j = 1:length(unique_times)
current_time = unique_times(j);
% Get all values for the current time point
current_values = age_data.DV(age_data.TIME == current_time);
% Calculate median
med_values(j) = median(current_values);
% Calculate 2.5th percentile
percentile_2_5(j) = prctile(current_values, 2.5);
% Calculate 97.5th percentile
percentile_97_5(j) = prctile(current_values, 97.5);
end
end
2 Comments
Where do you define age_data.TIME ?
age_ranges = [20 30;31 40;41 50;51 60;61 70]; % Modify as needed
age_groups = cell(size(age_ranges, 1), 1);
age_data = age_groups{1};
% Number of unique time points
unique_times = unique(age_data.TIME);
Stephen23
on 9 May 2024
age_groups = cell(size(age_ranges, 1), 1);
..
age_data = age_groups{i};
AGE_DATA is an empty double (the default array in a cell). Why do you expect an empty double to have any fields?
Accepted Answer
More Answers (0)
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!