50 likes | 145 Views
Introduction to MATLAB. ENGR 1181 MATLAB 1. MATLAB Built-in Math Functions. Pre-defined in MATLAB ready for use exp (x) – exponential (e x ) log(x) – natural logarithm (log e (x)) log10(x) – base 10 logarithm (log 10 (x)) sqrt (x) – square root (√x) abs(x) – absolute value (|x |).
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