incomplete command in TeX text string

1 回表示 (過去 30 日間)
Mathidiot Superfacial
Mathidiot Superfacial 2016 年 2 月 18 日
回答済み: Walter Roberson 2016 年 2 月 18 日
function []=printpowerf(x,y,z)
%this function print a power function onto the plot
%x and y are coordinates about where you want to put the graph
%z is the the coefficients containing alpha and beta of the power fucntion.
string1=['y=',z(1),'*x^',z(2)];
text(x,y,string1);
end
I'm trying to create a function to help me draw equations on plots. Codes above doesn't draw z values out and command window says incomplete command in TeX text string

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 2 月 18 日
string1 = sprintf('y = %f * x^{%f}', z(1), z(2))
Remember, using [] concatenation of a numeric value against a string is like using char() on the numeric values, and that means "look in the Unicode tables" rather than "format a number to be printable". Like char(10) does not mean '10', it means Unicode character #10, newline.

カテゴリ

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