combining string and numerical values

7 ビュー (過去 30 日間)
Andrew Waller
Andrew Waller 2016 年 9 月 30 日
コメント済み: Andrew Waller 2016 年 9 月 30 日
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

採用された回答

KSSV
KSSV 2016 年 9 月 30 日
doc fprintf ..
fprintf('f(x,y) has a saddlepoint at %f\n', x_crit(k))
  1 件のコメント
Andrew Waller
Andrew Waller 2016 年 9 月 30 日
perfect, thanks!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by