How to insert two variables into a sprintf string?

5 vues (au cours des 30 derniers jours)
Joe DuCharme
Joe DuCharme le 4 Août 2016
Commenté : Joe DuCharme le 5 Août 2016
I have created an fft plot of some data where the peaks are labeled with their values. Each peak indicates the order for. The first peak is first order, second is second order, and so on. I want the data label to say 1,2,3... order = peak value. All I can come up with is how to get order = value. How can I make it so that I can insert another variable into sprintf.
Here is what I have so far..
for ii=2:13
o=(ii-1)
text(f(locs(ii)), pks(ii),sprintf(' Order = %6.3f N',pks(ii))))
end
How can I add the variable o before order?
I would appreciate any input.
  1 commentaire
Azzi Abdelmalek
Azzi Abdelmalek le 4 Août 2016
You can make your question clear, explain your problem with an example and the expected result.

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 4 Août 2016
sprintf('o = %g, Order = %6.3f', o, pks(ii))
  1 commentaire
Joe DuCharme
Joe DuCharme le 5 Août 2016
Exactly what I was looking for. Thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by