A = rand(3, 4); % 3×4 matrix of random values between 0 and 1
disp('2D Array:');
disp(A);
% Mean calculations
mean_cols = mean(A); % Mean of each column (returns 1×4)
mean_rows = mean(A, 2); % Mean of each row (returns 3×1)
overall_mean = mean(A(:)); % Mean of all elements
% Display
disp('Mean of each column:');
disp(mean_cols);
disp('Mean of each row:');
disp(mean_rows);
fprintf('Overall Mean: %.4f\n', overall_mean);
plot(mean_cols, '-o'); % Line with circle markers
title('Mean of Each Column');
xlabel('Column Number');
ylabel('Mean Value');
grid on;
x = -pi:0.1:pi;
plot(x, cos(x))
To embed this program on your website, copy the following code and paste it into your website's HTML: