how to say a number in the title

5 次查看(过去 30 天)
Sameer
Sameer 2014-5-13
回答: nl2605 2014-5-13
'Probability greater than swtNPVProb(i,1)'
i is the loop variable. how do i get it to say the number associated with the variable in each loop, and report that number to the screen?

回答(3 个)

Walter Roberson
Walter Roberson 2014-5-13
title(sprintf('Probability greater than swtNPVProb(%d,1)', i))
  1 个评论
Sameer
Sameer 2014-5-13
that did not work. I am trying to create a loop with this vector:
swtCI = [.99 .95 .50 ]';
and i want the title to output to the screen these numbers, instead of swtCI(i,1).
i used disp('Upper Bound for swtCI(i,1)'); but that just gives me swtCI(i,1)

请先登录,再进行评论。


Sagar Damle
Sagar Damle 2014-5-13
Try this -
swtCI = [.99 .95 .50 ]';
for i = 1:length(swtCI)
disp(['Upper Bound for ',num2str(swtCI(i,1))]);
end
This is because,disp() requires its all arguments of same datatype.

nl2605
nl2605 2014-5-13
title(['Probability greater than swtNPVProb(',num2str(i),',1)']); However, in the same plot the last value would appear.

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by