Matlab mixed with Word, Excel

Source: Internet
Author: User

Mrs. Wah: Our notebook was started by mathwork company in MATLAB5.0, the realnowthe connection between MATLAB and Word.
Tong Pak-fu: Hum! Our Excellink is an Excel and MATLAB connection implemented in a Windows environment. Mrs. Wah: With our notebook, we can "enjoy" MATLAB in the word environment .the vast scientific and technological resources, feel the word processing, scientific calculation, engineering design in one of the perfect environment.
Tong Pak-fu: Not wrong! And with our Excellink friends, in the worksheet space and macro programming tools to make with the numerical calculation of MATLAB, graphics processing and other functions, there is no need to leave the Excel environment. reallyIt's a home trip .....
Mrs. Wah: Kill people kill ...
Tong Pak Fu, Mrs. Hua: the necessary medicine!!!
Oh, open a joke, cut into the subject ha.
One, MATLAB and word mixed use
Of course, our computer has MATLAB and word, generated MATLAB netobook files are also known as m-book files. The following are examples of the versions of Matlab r2014a and Microsoft Office Word 2003, with a slight discrepancy in the other versions. 1.   Netobook installation and use of the environment. start the MATLAB command window, where you enter:>>notebook-setupget the following tips:in this way, you can use MATLAB notebook. There are two ways to open notebook. (1) Output in MATLAB command window:>>notbook% Create a new M-book
(2) Open the M-book.dot file directly. 2. Netobook instances  in fact, notebook is a Word template document. It interacts with MATLAB through dynamic linking. The basic unit of interaction is the cell. M-book need to make a cell of a command or statement entered in Word. Again to run in MATLAB, the result of running the output continues to "cell" in the form of the present notebook. Here is the Netobook blank template: (unlike word, the notebook bar below)             (1), the basic process of executing the order
    • Enter the command in text format, not press Enter and space at the end of the command;
    • Select the "Define input cell" option from the notebook menu to define the input cells;
    • Select the "Evaluate Cell" option or Ctrl+enter from the notebook menu.
The input cells show black brackets including the green characters, the output of the cells are black brackets include the blue characters, if there is error black brackets include the red characters, the other text defaults to the brown character (if it is not easy to find a loss can be edited in the Mtalb editor first). such as:  to convert the output cells to normal text, select the cells you want to convert, and in the Notebook menu, select "Undefine cells" or alt+u. (2), exampleThe code is as follows:
1t=0:0.1: -;2y=1-cos (t). *exp (-t/5);3time=[0, -, -,0];4amplitude=[0.95,0.95,1.05,1.05];5Fill (Time,amplitude,'g'), Axis ([0, -,0,2]);6Xlabel (Time'), Ylabel ('Amplitude');7  on8Plot (T,y,'R','linewidth',2)9 Hold offTenYmax=min (y)

The results are as follows:

  

3, notebook use of a few small problems  
    • Graphical interaction instructions with mouse actions are best not to run in the notebook document;
    • The mtalab instruction runs more slowly in the M-book document than it does in the MATLAB command window;
    • When you need to print a Word document, you can convert cells to normal text, and if you print in a cell format, it will affect the printing effect.
ii. Mixed use of MATLAB and Excel    when using exce on the basis of MATLAB, it is slightly different from word and requires a plug-in link, called Excel link.  Through the link between the two, the user can use Excel's macro programming tool in the Excel workspace, and it can guarantee the exchange of data and update synchronously in two working environments.     in the initial installation of MATLAB, the default installation component is selected by the Excel link. Down is really the corresponding setting for Excel link: 1. Installation of Excel link  
    • Start Microsoft Excel and locate add-ins under the Tools menu bar.
    • After you open add-ins, click Browse, then select the Excllink.xla file under the user's own C:\Program files\matlab\r2014a\toolbox\exlink, and click OK.
    • Return to the Add-ins window and click OK. You can see the changes in the Excel window as follows: 

   2. Set the start of Excel link

When the installation is complete, Excel link and Matlab will run automatically each time you start Excel. If you do not want to run, you can enter the =mlautostart ("no") function in the Excel data table cell. When you start Excel again, Excel link and MATLABJ will no longer start.

afterYou can also manually start Excel link and Matlab in Excel. On the Tools menu, choose Macro, then macro, and enter Matlaninit in the Macro dialog box that opens.
  3. Terminate the operation of Excel link  
When you terminate Excel, Excel link and Matlab are terminated at the same time. If you need to terminate Matlab and Excel Link in an Excel environment, enter "=mlclose ()" In the worksheet cell. When you need to restart Excel link and matlab, you can select the Mlopen or Matlabinit command to start.
4. Excel Link Instance  
Open the sample file Exlisamp.xls that contains the installation path to C:\Program Files\matlab\r2014a\toolbox\exlink in MATLAB. 4.1. Data Sheet Execution Method    Click the shteel tag in Exlisamp.xls to see that the datasheet contains an array a4:c28 named data. The steps are as follows:(1), select the unit E5, press F2 key, enter the function "=mlputmatrix (" Data "," data "), the data is copied into MATLAB. Data contains 25 observations of 3 variables, and the observed values are strongly linearly correlated;(2), for E8, E9, E10, E13, E16, E19, E20, E21, E24, E25, E28 do the same operation. The code is as follows:
1x=1:1: -;2y1=[4583 4764 4955 5216 5327 5338 5439 602Ten 635 One 671 A 766 - 913 - 938 the 1013 - 1038 - 1134 - 1163 + 1319 - 1325 + 1591 A 2006 at 2043 - 2904 - 3282 - 5326 - ]; -y2=[379.047453 in 430.3098643 - 462.4722111 to 472.0222433 + 501.7970821 - 476.7972595 the 467.2472272 * 570.8967919 $ 641.1212438Panax Notoginseng 743.6460664 - 767.5211469 the 773.558929 + 1143.781253 A 1279.593164 the 1201.21947 + 1098.694648 - 1251.081092 $ 1478.743051 $ 1163.157365 - 1479.157123 - 2086.177367 the 2011.591971 - 2666.224352Wuyi 3483.345306 the 5197.79632 - ]; Wuy3=[402.0080047 - 515.8528028 About 549.7113505 $ 543.0183918 - 524.5498711 - 513.7749611 - 522.2080918 A 554.7609792 + 611.0946537 the 686.9714884 - 775.6072286 $ 869.0230193 the 959.3974346 the 1040.418506 the 1108.635751 the 1164.812202 - 1215.276435 in 1273.274596 the 1360.322433 the 1507.557324 About 1757.090302 the 2163.358088 the 2794.475118 the 3733.58557 + 5080.215396 - ]; thePlot (X,y1,'o', X,y2,':', X,y3,'-.')BayiLegend'Data','Fit','Newfit')

    The waveform figure is as follows:

data, fit and newfit three curves are compared, can be found to be very strong correlation, and not linear independent, fitting curve and raw data is not very consistent, but the 5-order polynomial fitting shows a more accurate mathematical model. 4.2. Macro command Execution Mode    Click the sheet tab to activate the unit A4, but don't do it first. Cell A4 calls the macro Curvefit to open Curvefit in the Visual Basic environment. The operation is as follows:
(1), in Excel, execute the Visual basic Editor in the Macro option under the Tools menu bar , and open the template folder in the project, such as:     (2), select Moduel, you can open the module, such as:(3), in the state of the module is open, click on the "Reference" command in its tool menu bar, click "Excellink" in the popup dialog box to load; (4), return to Sheet2 unit A4, press F2 Enter, perform macro curvefit. It copies the sorted data y,fit and newfit from Matlab to the datasheet. such as:5, Excel link uses a few small problems(1), the Excel link function performs a specific action when a function of Microsoft Excel returns a definite value, so Excel's operations and functions behave differently under the control of the Excel link function. (2), most Excel link functions have two ways of defining variables, that is, the direct and indirect way. Variables are directly defined with double quotation marks, such as "=mldeletematrix (" Bonds "), where the workspace cell address or column name without double quotation marks in the function is treated as an indirect variable, and the function operates on its guide content.   The address of the workspace cell can contain the page table number.

Matlab mixed with Word, Excel

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.