Current location - Music Encyclopedia - Today in History - How to clear your own input data in matlab workspace?
How to clear your own input data in matlab workspace?
You can use xlswrite function directly in M file: (file name/worksheet/range are enclosed in single quotation marks)

Xlswrite (file name, m); Write the data of matrix M into an Excel file named filename.

Xlswrite (file name, m, worksheet); Write the data of matrix m into the table specified in the file name.

Xlswrite (file name, m, range); Write the data in the matrix m into an Excel file with the file name as and the storage area determined by the range, for example,' C 1:C2'.

Xlswrite (file name, m, worksheet, range); Specify the paper to be stored according to the previous command.

Status = xlswrite (file name, ...); Returns the completion status value. If the writing is successful, the status is1; On the other hand, if the write fails, the status is 0.

[Status, Message] = xlswrite (file name, ...); Returns any error or warning messages caused by the write operation.

Application example

Example 1: Write data to the default worksheet.

Write the seven-element vector into testdata.xls By default, data will be written to cells A 1 to G 1 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 worksheet.

d = {'Time ',' Temp '; 12 98; 13 99; 14 97};

S = xlswrite('tempdata.xls', d,' temperature',' E 1')

s =

1

Time temperature

12 98

13 99

14 97

Example 3: Adding a New Worksheet to a File

Now, write the data in the above example into a worksheet that does not exist in tempdata.xls. In this case, xlswrite will add a new worksheet with the user-specified name, and xlswrite will display a warning that a new worksheet has been added. xlswrite('tempdata.xls ',d,' NewTemp ',' E 1 ')

Warning: The specified worksheet has been added.

If you don't want to see these warnings, you can enter the following command.

Warning close MATLAB:xlswrite:AddSheet

Enter the write command again, and create another new worksheet NewTemp2 this time. At this point, the prompt message will not be displayed, but the message can still be extracted by using the msg command.

[stat msg]= xls write(' tempdata . xls ',d,' NewTemp2 ',' e 1 ');

monosodium glutamate

Message =

Message: "The specified worksheet has been added."

Identifier: "MATLAB:xlswrite:AddSheet" book.