bar plot with two y-axis one for sum of squared error value and the second for adjusted r squared and f-statistic values with 6 bar plot in one figure padding with zeros in matlab

To create a bar plot with two y-axes in MATLAB, you can use the yyaxis() function. Here's an example of how you can create a bar plot with six bars, where the first y-axis represents the sum of squared error value and the second y-axis represents the adjusted r squared and f-statistic values:

main.m
% Input data
sseValues = [10 15 7 20 12 8];
adjRSquared = [0.6 0.65 0.55 0.7 0.63 0.58];
fStatistic = [2.5 3.1 2.2 3.5 2.9 2.6];

% Create figure and bar plot
figure;
bar(sseValues, 'r'); % Bars for sum of squared error value
hold on;
yyaxis right;
bar([adjRSquared; fStatistic]','b') % Bars for adjusted r squared and f-statistic values

% Add padding with zeros
numBars = numel(sseValues); % Get the number of bars
padding = zeros(1, numBars); % Create an array of zeros for padding
yyaxis left;
hold on;
bar(padding,'w'); % Add padding with zeros for the left y-axis

% Set labels and titles
xlabel('Data Points')
ylabel('Sum of Squared Error Value')
yyaxis right;
ylabel('Adjusted R Squared and F-Statistic')
legend('Sum of Squared Error', 'Adjusted R Squared', 'F-Statistic')
781 chars
26 lines

This code will create a bar plot with six bars, where the sum of squared error values will be represented on the left y-axis (in red) and the adjusted r squared and f-statistic values will be represented on the right y-axis (in blue).

Note that padding with zeros has been added for the left y-axis to match the number of bars on the right y-axis.

Make sure to replace the input data (sseValues, adjRSquared, fStatistic) with your own data.

I hope this helps!

gistlibby LogSnag