Why are title and label not working on histogram?

28 次查看(过去 30 天)
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

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Title 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by