This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
matlab_guide [2015/08/11 14:07] graham |
matlab_guide [2016/05/09 09:29] (current) a_west [Interp] |
||
|---|---|---|---|
| Line 48: | Line 48: | ||
| * [[matlab_guide#Files| Files]] | * [[matlab_guide#Files| Files]] | ||
| * [[matlab_guide#fopen| fopen]] | * [[matlab_guide#fopen| fopen]] | ||
| - | * [[matlab_guide#fscan| fscan]] | + | * [[matlab_guide#fscanf| fscanf]] |
| * [[matlab_guide#fclose| fclose]] | * [[matlab_guide#fclose| fclose]] | ||
| * [[matlab_guide#Audio| Audio]] | * [[matlab_guide#Audio| Audio]] | ||
| Line 63: | Line 63: | ||
| ===== Matlab Basic Operations ===== | ===== Matlab Basic Operations ===== | ||
| - | |||
| === Introduction === | === Introduction === | ||
| - | MATLAB is a numeric computation computer software. All of the data types are matrices that can | + | MATLAB is a numerical computation computer software. All of the data types are matrices that can |
| - | either represent numeric or string variables. It is also case sensitive. i.e. a is not the same as B. | + | either represent numeric or string variables. It is also case sensitive (i.e. 'b' is not the same as 'B'). |
| === Basic setup === | === Basic setup === | ||
| - | When you open up MATLAB you have three basic windows available: Current Folder, Command Window, and Workspace. | + | When you open up MATLAB you have three basic windows available: Current Folder, Command Window, and Workspace. |
| + | |||
| The Current Folder window informs the user what folder MATLAB is currently working out of, and displays all of | The Current Folder window informs the user what folder MATLAB is currently working out of, and displays all of | ||
| the files located withing that folder. The Command Window prompts the user for input by the **>>** symbol. Once | the files located withing that folder. The Command Window prompts the user for input by the **>>** symbol. Once | ||
| Line 216: | Line 215: | ||
| </code> | </code> | ||
| - | Length returns the number size of the largest dimension. If row >> column then it will return the length of | + | Length returns the number size of the largest dimension. If row > column then it will return the length of |
| - | the row. If column >> row then it will return the length of the row. | + | the row. If column > row then it will return the length of the column. |
| <code> | <code> | ||
| Line 1446: | Line 1445: | ||
| //A = fscanf(variable_name,formatSpec);//\\ | //A = fscanf(variable_name,formatSpec);//\\ | ||
| - | Example: | + | **Example:** |
| File count.dat contains three columns of integers. Read the values in column order, | File count.dat contains three columns of integers. Read the values in column order, | ||
| and transpose to match the appearance of the file: | and transpose to match the appearance of the file: | ||
| Line 1468: | Line 1467: | ||
| ===== sound ===== | ===== sound ===== | ||
| == External Resources == | == External Resources == | ||
| + | [[https://www.youtube.com/watch?v=ie7iREcYBPU|Great tutorial about combining drums, bass, and a guitar wave files]] | ||
| == Description == | == Description == | ||
| - | ====== Interp ====== | + | Play an array as sound\\ |
| + | |||
| + | **Syntax**\\ | ||
| + | //sound(Y,FS);// sends the signal in array Y (with sample frequency FS) out to the speakers\\ | ||
| + | |||
| + | **Example:**\\ | ||
| + | load handel | ||
| + | sound(y,Fs) | ||
| + | You should hear a snippet of Handel's Hallelujah Chorus. | ||
| + | |||
| + | Type //'help sound'// in the command window for more details | ||
| + | ====== Interpolation ====== | ||
| == External Resources == | == External Resources == | ||
| == Description == | == Description == | ||
| + | Increases the Sample rate by an integer factor. | ||
| + | |||
| + | **Syntax:**\\ | ||
| + | //y = interp(x,r);// This increases the sampling rate of x (input signal) by a factor of r. | ||
| + | **Example: **\\ | ||
| + | Create a sinusoidal signal that is sampled at 1kHz. Upsample by 6 | ||
| + | t = 0:0.01:1; | ||
| + | x = sin(2*pi*30*t) | ||
| + | y = interp(x,6); | ||
| + | | ||
| + | Type //'help interp'// in command window of matlab for more details. | ||