incomplete command in TeX text string

1 view (last 30 days)
Mathidiot Superfacial
Mathidiot Superfacial on 18 Feb 2016
Answered: Walter Roberson on 18 Feb 2016
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

Answers (1)

Walter Roberson
Walter Roberson on 18 Feb 2016
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.

Categories

Find more on Characters and Strings in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!