Hello Devela,
The error message you are encountering suggests that the inputs to the text function are not in the correct format. In particular, the x and y coordinates provided to text should be vectors of the same length, corresponding to the positions on the plot where you want to place the labels.
In your subplot example, you are likely passing an entire matrix ( combined_graph_100m ) to the text function instead of a specific column or row. Here is how you can fix the issue:
- Ensure Correct Dimensions: Make sure the x and y inputs to the text function are vectors of the same length.
- Iterate Over Subplots: If you are using a loop to create multiple subplots, ensure that each subplot has its own corresponding labels.
Here is an example of how you can modify your code to work with subplots:
combined_graph_100m = [70.8, 19.2, 10; 60, 25, 15];
y_values = combined_graph_100m(i, :);
bar(xval2, y_values, 0.4);
text(xval2, y_values, cellstr(num2str(labels')), 'VerticalAlignment', 'bottom', ...
'HorizontalAlignment', 'center');
title(['Subplot ' num2str(i)]);
You will be able to see a plot like:
I hope this helps!