- Organize the Data: Merge the data from both matrices into a single array, associating each row with its respective category.
- Plot the Histogram: Use MATLAB's 'histogram' function to visualize the data.
plotting histogram of 3d data.
17 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to plot catagorical histogram of following 3d data.
MATRIX 1
Y 48 98 111
Y 33 73 97
Y 65 97 124
Y 73 93 128
MATRIX 2
N 21 74 113
N 40 70 121
N 41 68 107
N 41 68 107
ON A single histogram
kindly help
0 Kommentare
Antworten (1)
Naga
am 23 Okt. 2024
Hello Farhan
To create a categorical histogram of your 3D data in MATLAB, follow these steps:
% Data from Matrix 1
data1 = [48, 98, 111; 33, 73, 97; 65, 97, 124; 73, 93, 128];
category1 = repmat({'Y'}, size(data1, 1), 1);
% Data from Matrix 2
data2 = [21, 74, 113; 40, 70, 121; 41, 68, 107; 41, 68, 107];
category2 = repmat({'N'}, size(data2, 1), 1);
% Combine data and categories
data = [data1; data2];
categories = [category1; category2];
% Step 2: Plot the Histogram
% Flatten the data and categories for histogram plotting
flattenedData = data(:);
flattenedCategories = repmat(categories, 1, size(data, 2));
flattenedCategories = flattenedCategories(:);
% Create a categorical array
categoricalData = categorical(flattenedCategories);
% Plot the histogram
figure;
histogram(categoricalData, 'DisplayStyle', 'bar', 'FaceColor', 'b');
xlabel('Category');
ylabel('Frequency');
title('Categorical Histogram of 3D Data');
This script will generate a categorical histogram where the categories 'Y' and 'N' appear on the x-axis, and the frequency of each category is displayed on the y-axis.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Histograms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!