How to add plot titles in a for loop

I want to add a title to these plots that changes in each loop
AccNames = {'Longnitudinal'; 'Lateral'; 'Normal'; 'Pitch'; 'Roll'; 'Yaw'};
for i = 1:6
figure()
histogram(TaxiRevy{i},100,'normalization','probability')
title(sprintf('Exceedence Diagram of %d Accelaration', AccNames{i}))
end
This code returns two and tree digit numbers inserted into the title, not the strings specified, if anyone could give me some guidance i'd be very grateful!

 採用された回答

Jos (10584)
Jos (10584) 2018 年 2 月 15 日

2 投票

You use the wrong format identier (%d) in sprintf,, which should be %s:
X = 'Jasper'
sprintf('Hello %s!', X)
(and you misspelled longnitudinal, remove the n after the g ;)

1 件のコメント

jasper wagen
jasper wagen 2018 年 2 月 15 日
Thanks for the help!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by