MATLAB is a technical computing program used in the engineering and scientific community for data processing and analysis. MATLAB allows the user to manipulate large data sets typically represented in arrays and matrices. You need to visualise data after they are in the correct form. Multiple data sets plotted on the same graph require a legend to differentiate between each line.
- Skill level:
- Moderately Easy
Other People Are Reading
Clear all active variables in the workspace by entering "clear all" in the "Command" window.
Plot the data. Enter the appropriate plotting function into the command window. To create sample data input "x=(1:1:10);" and "y=rand(1,10);". Next enter "plot(x,y);". into the command window. Do not press "Enter."
Enter on the same line of code "legend('dataname')" where dataname is the name shown on the legend included on the plot. Press "Enter." The legend appears on the top right of the plot.
Click "Show Plot Tools and Dock Figure." Once "Plot Tools" opens, click on the legend that displays a location selector on the bottom left. Select an appropriate location for the legend.
Tips and warnings
- If the data are already plotted, click "Insert-Legend" in the "Figure" menu.
- If multiple data sets are plotted on the same graph, enter legend('dataset1', 'dataset2') where dataset1 and dataset2 are the names of the data.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for