Equation of the Line in command window
3 views (last 30 days)
Show older comments
I have a graph, with an equation, but i need to display that equation into the command window.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/375361/image.jpeg)
0 Comments
Accepted Answer
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
on 8 Oct 2020
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!