combining string and numerical values

7 vues (au cours des 30 derniers jours)
Andrew Waller
Andrew Waller le 30 Sep 2016
Commenté : Andrew Waller le 30 Sep 2016
Within my conditional analysis of a program I'm working on that basically evaluates partial derivatives to give characteristics of a function, I'm trying to combine a string 'a numerical example is' with a chosen number from an array (example(k)). I've tried a few different methods and I believe I need to utilize num2str but when I try to use it, I get back the error "Input to num2str must be numeric." which doesn't make sense because my value is in fact a number?
Just for trouble shooting purpose I tried int2string and was able to get a number but obviously I need the full number, not just an integer.
for k = 1:numel(B)
if (A(k))>0
if(B(k))<0
disp(['f(x,y) has a saddlepoint at' num2str(x_crit(k)) ])
end
end
end
If it helps these are the values I'm trying to call into the string. Thanks in advance for the help!
x_crit =
0
-13/10
13/10
0
0
-13/20
13/20
-13/20
13/20

Réponse acceptée

KSSV
KSSV le 30 Sep 2016
doc fprintf ..
fprintf('f(x,y) has a saddlepoint at %f\n', x_crit(k))

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by