Dot indexing is not supported for variables of this type
I am not able to understand why this error occurs. Could any one please correct me here. [Kindly look for underlined 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);
% 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);
endI am not able to understand why this error occurs. Could any one please correct me here. [Kindly look for underlined 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);
% 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 I am not able to understand why this error occurs. Could any one please correct me here. [Kindly look for underlined 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);
% 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 dot indexing MATLAB Answers — New Questions