In order to plot a pie chart in MATLAB wherin one of the variables is dependant upon the another variable like 'Var1' dependant on 'Var2', consider using 'groupsuummary' and 'pie' functions provided by MATLAB.
Here is an example:
my_data = readtable(filename) % Reading file with data.
groupedData = groupsummary(my_data, 'Var1', 'sum', 'Var2'); % Group by 'Var1' and sum 'Var2'
figure;
pie(groupedData.sum_Var2, groupedData.Var1); % Create pie chart
title('Pie Chart of Var1 grouped by Var2');
Consider referring to the following MATLAB Answers:
The following MathWorks documentations can be referred to know more:
Hope this helps. Thanks.
