- #1

- 11

- 0

You are using an out of date browser. It may not display this or other websites correctly.

You should upgrade or use an alternative browser.

You should upgrade or use an alternative browser.

In summary, the person is looking for help on how to draw a straight line graph with a best fit line and determine its slope in MATLAB. They have had difficulty finding resources online and have a list of voltage measurements and corresponding speeds. They are provided with a link that explains how to perform linear curve fitting in MATLAB.

- #1

- 11

- 0

Physics news on Phys.org

- #2

- 277

- 1

Check if this link helps

http://www.swarthmore.edu/NatSci/echeeve1/Ref/Matlab/CurveFit/LinearCurveFit.html [Broken]

http://www.swarthmore.edu/NatSci/echeeve1/Ref/Matlab/CurveFit/LinearCurveFit.html [Broken]

Last edited by a moderator:

- #3

- 11

- 0

perfect. exactly. thanks.

To draw a simple graph in MATLAB, you can use the `plot()`

function. This function takes in two vectors as its input, where the first vector represents the x-coordinates and the second vector represents the y-coordinates of the points on the graph. For example, `plot([1,2,3],[4,5,6])`

will plot three points with coordinates (1,4), (2,5), and (3,6) on a graph.

Yes, you can customize the appearance of your graph in MATLAB by using additional arguments in the `plot()`

function. For example, `plot(x,y,'r--o')`

will plot a red dashed line with circles at each data point. You can also add a title, axis labels, and legend to your graph using the `title()`

, `xlabel()`

, `ylabel()`

, and `legend()`

functions, respectively.

To save your graph in MATLAB, you can use the `saveas()`

function. This function takes in two arguments - the handle of the figure you want to save and the file name. For example, `saveas(gcf, 'mygraph.png')`

will save the current figure as a PNG image with the file name "mygraph". You can also specify the file format by using the appropriate file extension, such as .jpg or .pdf.

To add multiple lines to your graph in MATLAB, you can use the `hold on`

command. This command allows you to plot multiple lines on the same graph without overwriting the previous lines. For example, `plot(x,y1)`

followed by `hold on`

and `plot(x,y2)`

will plot two lines on the same graph. Don't forget to use `hold off`

when you're done plotting to turn off this feature.

To plot a function in MATLAB, you can use the `fplot()`

function. This function takes in two arguments - the function you want to plot and the range of values for the independent variable. For example, `fplot(@(x) x^2, [-5,5])`

will plot the function f(x) = x^2 for x values ranging from -5 to 5. You can also customize the appearance of the graph by adding additional arguments, such as line style and color.

Share:

- Replies
- 4

- Views
- 455

- Replies
- 5

- Views
- 917

- Replies
- 4

- Views
- 2K

- Replies
- 2

- Views
- 2K

- Replies
- 4

- Views
- 1K

MATLAB
How to plot data in MATLAB?

- Replies
- 2

- Views
- 1K

- Replies
- 2

- Views
- 645

- Replies
- 1

- Views
- 3K

- Replies
- 5

- Views
- 2K

- Replies
- 32

- Views
- 2K