Equation of the Line in command window

10 views (last 30 days)
I have a graph, with an equation, but i need to display that equation into the command window.

Accepted Answer

Star Strider
Star Strider on 8 Oct 2020
Try this:
B = [y(:) ones(size(y(:)))] \ x(:);
fprintf('Linear: y = %.4f*x%+.2f', B) % Display In Command Window
text(0, max(ylim), sprintf('Linear: y = %.4f*x%+.2f', B), 'HorizontalAlignment','left', 'VerticalAlignment','top') % Display On Plot
.
  4 Comments
Star Strider
Star Strider on 8 Oct 2020
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Sign in to comment.

More Answers (0)

Categories

Find more on Large Files and Big Data in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!