I was wondering if it is possible to plot a line of the form y = mx+b
in Matlab? I used polyfit
to get a 1x2 array that contains the slope and intercept.
Here is what I have so far:
lineFit = polyfit(tauBin, a5array, 1);
plot((lineFit(1)*x + lineFit(2)))
How can I plot this?
There are two way that immediately come to mind. The first is with FPLOT:
>> m = 2; b = 1; >> fplot(@(x)m*x+b, [0 10]);
The second is to calculate the y values directly in the call to the PLOT command:
>> m = 2; b = 1; x = 1:10; >> plot(x, m*x+b);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With