50 likes | 150 Views
Explore MATLAB's extensive library of built-in math functions like exp, log, sqrt, and abs. Learn how to format plots with titles, labels, legends, and line specifiers. Input strings using the input() command effortlessly.
E N D
Introduction to MATLAB ENGR 1181 MATLAB 1
MATLAB Built-in Math Functions • Pre-defined in MATLAB ready for use • exp(x) – exponential (ex) • log(x) – natural logarithm (loge(x)) • log10(x) – base 10 logarithm (log10(x)) • sqrt(x) – square root (√x) • abs(x) – absolute value (|x|)
Plot Formatting • Title: title('Distance vs. Intensity') • Axis Labels: xlabel('Intensity , w/m^2')ylabel('Distance, m') • Legend: legend('Data Set 1', 'Data Set 2’)
Line Specifiers • Allow you to change the type of line and markers on the plot • Refer to your book, or type: help plot for syntax and options
Input a String to a Script File • The input() command can also be used for a string input. • The user does not need to know or understand what a string is or what is happening in the code. y = input('text’,’s’) Adding the ,’s’ will convert the input to a string