incomplete command in TeX text string

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by