1. Use the audioread(''); function to read the audio file in the computer. The parameter is the path of the audio file:
[sampledata,FS] = audioread('F:1.mp3');
sampledata saves audio signal data, FS is the audio sampling rate, and the sampling rate of MP3 format is generally 44100;
Determine whether the audio data is binaural. If it is binaural, retain the data of one channel. You can use the function of the calsample.m file to achieve this. The content of the file is as follows:
function sample = calsample(sampledata,FS)
temp_sample = resample(sampledata,1,FS/11025);
[m,n] = size(temp_sample);
if (n == 2)
sample = temp_sample(:,1);
else
sample = temp_sample;
end
end
A. Use a simple UPDATE
The following example shows how all rows will be affected if the WHERE clause is removed from the UPDATE statement.
The following example illustrates how the publishers table is updated if all publishers in the publishers table move their headquarters to Atlanta, Georgia.
UPDATE publishers
SET city = 'Atlanta', state = 'GA'
This example changes all publisher names to NULL.
UPDATE publishers
SET pub_name = NULL
Calculated values can also be used in updates. This example doubles all prices in the titles table.
UPDATE titles
SET price = price * 2
B. Use the WHERE clause with the UPDATE statement
The WHERE clause specifies the rows to be updated. For example, in the following fictional event, Northern California was renamed Pacifica (abbreviated as PC), and the citizens of Oakland voted to change the name of their city to Bay City. This example shows how to update the authors table for all previous residents of Oakland City whose addresses are out of date.
UPDATE authors
SET state = 'PC', city = 'Bay City'
WHERE state = 'CA' AND city = 'Oakland'
Another statement must be written to change the state name for residents of other Northern California cities.
C. Use information from another table through the UPDATE statement
This example modifies the ytd_sales column in the titles table to reflect the latest sales records in the sales table.
UPDATE titles
SET ytd_sales = titles.ytd_sales sales.qty
FROM titles, sales
WHERE titles.title_id = sales.title_id
AND sales.ord_date = (SELECT MAX(sales.ord_date) FROM sales)
This example assumes that a specific product records only one batch of sales on a specific date, and the update is the latest. If this were not the case (i.e. if more than one batch of sales could be recorded for a particular item on the same day), the example shown here would be wrong. The example works correctly, but each item is updated with only one batch of sales, regardless of how many batches were actually sold that day. This is because an UPDATE statement never updates the same row twice.
For situations where more than one batch of a specific item can be sold on the same day, all sales for each item must be totaled together in the UPDATE statement, as shown in the following example:
UPDATE titles
SET ytd_sales =
(SELECT SUM(qty)
FROM sales
WHERE sales.title_id = titles.title_id
AND sales.ord_date IN (SELECT MAX(ord_date) FROM sales))
FROM titles, sales
D. Using the UPDATE statement with the TOP clause in a SELECT statement
This example updates the state column of the first ten authors from the authors table.
UPDATE authors
SET state = 'ZZ'
FROM (SELECT TOP 10 * FROM authors ORDER BY au_lname) AS t1
WHERE authors.au_id = t1.au_id
You can use the xlswrite function directly in the m file: (filename/sheet/range must be added in single quotes)
xlswrite(filename, M); Write the data of matrix M into the Excel file named filename.
xlswrite(filename, M, sheet); Write the data of matrix M to the specified sheet in filename.
xlswrite(filename, M, range); Write the data in matrix M to the Excel file named filename, and the storage area is specified by range, such as 'C1:C2'.
xlswrite(filename, M, sheet, range); Specifies the sheet to be stored based on the previous command.
status = xlswrite(filename, ...); Return the completion status value. If the writing is successful, the status is 1; otherwise, the writing fails, the status is 0.
[status, message] = xlswrite(filename, ...);Return any error or warning information generated due to the write operation
Application examples
Example 1: Write data to the default worksheet
Write a seven-element vector into testdata.xls. In the default format, data will be written to cells A1 to G1 of the first worksheet in the file. xlswrite('testdata.xls', [12.7 5.02 -98 63.9 0 -.2 56])
Example 2: Write mixed data into the specified worksheet
d = {'Time', 'Temp'; 12 98; 13 99; 14 97};
s = xlswrite('tempdata.xls', d, 'Temperatures', 'E1')
The above is the detailed content of How to extract speech database using MATLAB. For more information, please follow other related articles on the PHP Chinese website!