Why are title and label not working on histogram?

43 views (last 30 days)
I have two subplots, both containing histograms but I can't add a title or labels to both of them.
Matlab tells me, that the value assigned to "title", "xlabel" and "ylabel" might be unused.
But I do want to use them.
This is my code so far:
subplot(1,2,1);
histogram(measurement1, 'BinEdges', [10:10:120], 'Normalization', 'probability');
title = ('Temperatures @ Top')
xlabel = ('Temperature')
ylabel = ('Probability')
subplot(1,2,2);
histogram(measurement2, 'BinEdges', [10:10:120], 'Normalization', 'probability');
title = ('Temperatures @ Bottom')
xlabel = ('Temperature')
ylabel = ('Probability')
Any help appreciated

Accepted Answer

Constantino Carlos Reyes-Aldasoro
You are using the commands incorrectly, by writing title = ('Temperatures @ Top') you are creating a new variable called title with the values that you pass, the correct sintax is the following
measurement1 = 100*randn(100,1);
subplot(1,2,1);
histogram(measurement1, 'BinEdges', [10:10:120], 'Normalization', 'probability');
title ('Temperatures @ Top')
xlabel ('Temperature')
ylabel ('Probability')
Hope that solves your problem

More Answers (0)

Products


Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!