Products & Services Industries Academia Support User Community Company

Learn more about MATLAB   

Producing Published Output from M-Files

About Producing Published Output

Once you have formatted an M-file for publishing, as described in Formatting M-File Comments for Publishing and Formatting M-File Code for Publishing you are ready to publish it. The easiest method for publishing an M-file is to use factory default publishing properties. This method is appropriate if your M-file requires no input arguments and you want to publish to HTML. However, if your M-file requires input arguments, or you want to specify preferences for publishing, such as the output folder, output format, image format, and so on, you need to specify custom property settings.

Publishing M-Files Using No Input Arguments and Factory Default Settings

To publish a script M-file, or a function M-file that requires no input arguments:

  1. Open the file in the Editor.

  2. Click the Publish button on the Editor toolbar.

By default, the Editor publishes the file using factory default settings. Factory default settings specify that the output file format is HTML, that the M-code is evaluated and included in the published output file, and so on.

If the file is neither in a folder on the search path, nor in the current folder, a dialog box opens and presents you with options that allow you to publish the file. You can either change the current folder to the folder containing the file, or you can add the folder containing the file to the MATLAB search path.

If the file has unsaved changes, publishing it from the Editor automatically saves the changes before publishing.

Using Publish Configurations to Publish M-Files with Input Arguments or Custom Settings

Using a publish configuration, you can specify custom settings, including input arguments for a function M-file in the Editor. You can associate multiple publish configurations with an M-file for different publish settings, input arguments, or both. MATLAB saves the configuration between sessions.

For example, the function collatzplot_new.m, which computes and plots the Collatz sequence for any given positive integer, requires you to specify the integer as an input value. You cannot simply publish collatplot_new.m because the input value is not defined. A publish configuration enables you to publish collatzplot_new(specific value).

You can also use publish configurations to provide preparatory or setup information prior to publishing an M-file, whether it takes input arguments or not.

Function Alternative to Publishing

From the Command Window, execute the publish function to run the M-file and publish the results. See the publish function reference page for options you can set.

Creating a Publish Configuration for an M-File

Specifying M-File Input Using a Publish Configuration

Follow these steps to create a publish configuration for an M-file in the Editor. The example in this section shows how to create and use a publish configuration to specify input arguments to a function M-file.

These steps specify Editor toolbar buttons, but you can also use equivalent items in the File menu.

  1. Open the file that you want to publish in the Editor. This example uses the code that follows. This code is similar to the sine_wave.m file, after it has been formatted as described in Formatting M-File Comments for Publishing, but it is slightly altered to make it a function M-file. Save the code as sine_wave_f.m

    %% Plot Sine Wave
    % Calculate and plot a sine wave.
    
    %% Calculate and Plot Sine Wave
    % Calculate and plot |y = sin(x)|.
    
    function sine_wave_f(x)
    
    y = sin(x);
    plot(x,y)
    
    %% Modify Plot Properties
    
    title('Sine Wave', 'FontWeight','bold')
    xlabel('x')
    ylabel('sin(x)')
    set(gca, 'Color', 'w')
    set(gcf, 'MenuBar', 'none') 
  2. Click the down arrow next to the Publish button on the Editor toolbar, and click Edit Publish Configuration for file name, where file name in this example is sine_wave_f.m.

    Image of Publish button, including down arrow. The menu associated with the button is open and the following two menu items are presented: sine_wave_f and Edit Publish Configurations for sine_wave_f.m

    The Edit M-File Configurations dialog box opens, with the default publish configuration template for sine_wave_f.m, as shown in the following figure.

    Image of the Edit M-File Configurations dialog box with the default publish configuration settings displayed.

  3. In the Publish configuration name field, type a name for the publish configuration, or accept the default name.

    If you expect to create multiple configurations for an M-file, assign each a name that helps you identify the configuration. In this figure, the default name of the configuration is sine_wave_f.

  4. In the MATLAB expression field, type the expression that you want the Editor to evaluate when it publishes the M-file. In this example, delete the commented statements and replace them as shown in the following figure.

    You can modify the statements in the MATLAB expression area of the dialog box, and then click Publish to see the results of the changes. If you clear the MATLAB expression area, MATLAB publishes the M-file without evaluating any code. This is equivalent to setting the Evaluate code property in the Publish settings properties table to false.

  5. In the Publish settings properties table, change the property values if you do not want to use the current settings.

    You can modify the property settings, and then click Publish to see the results of the changes.

    See Specifying Values for the Publish Settings Property Table for details.

  6. Do one of the following:

    • To publish the file using the settings and MATLAB expression that you have specified, click Publish.

      For this example MATLAB creates the following files in I:\my_matlab_files\my_mfiles\html, which is a subfolder in the folder where sine_wave_f.m is located:

      • A published document file, sine_wave_f.html

      • A thumbnail file for the last image generated by the M-file code, sine_wave_f.png

      • Image files created by the executable M-file code, sine_wave_f_##.png

    • To create another publish configuration for the same M-file, click the plus button , and then select Publish Configuration.

      See Creating Multiple Publish Configurations for an M-File for details.

    • To close the Edit M-File Configurations dialog box, click Close. MATLAB saves the configuration and its association with the M-file.

After creating a configuration, you can view the MATLAB expression and use the configuration to publish the M-file without opening the Edit M-File Configurations dialog box. See Running an Existing Publish Configuration for details.

Specifying Publish Configuration Settings

This section describes how to specify new publish settings for a configuration. Publish settings enable you to specify the folder to which a published file is saved, how images generated by the M-code are captured and included in the published document, and so on.

  1. If the Edit M-File Configurations dialog box is not already open, click the down arrow on the Publish button and then click the configuration that you want to change.

    This example uses the sine_wave_f publish configuration as described in Creating a Publish Configuration for an M-File.

  2. View the properties table below the Publish settings field to see the current publish property values.

  3. For information about a property, click the property name. A brief description of that property displays below the publish settings property table. For example, if you click Catch error, the dialog box appears as shown in the following image.

    Image of Edit M-File Configurations dialog box with the Catch error property selected. At the bottom of the page, the following text is presented: Select true to publish the document, including the error message, if the M-file code generates an error. Select false to terminate publishing when an error occurs.

  4. Optionally, you can change publish setting values by clicking in the column to the right of the property name and then entering or selecting a property value. This example changes Max image width and Max image height to 400.

    The Editor marks each property that you change with a dot ( ) and adds the string, (modified), next to User Default in the Publish settings field.

    See Specifying Values for the Publish Settings Property Table for information about the various properties you can set.

    Image of Edit M-File Configuration dialog box, marked as described in the text preceding the image.

  5. Click Publish to preview the publication of the M-file that is open in the Editor using the new settings.

  6. When you are satisfied with the results, click Save As.

    The Save Publish Options dialog box opens and displays the names of all the currently defined publish settings. By default the following publish settings are installed with MATLAB:

    • Factory Default

      The MATLAB installation includes this named set of publishing properties for you to get started with publishing documents. It enables you to quickly publish an M-file to HTML and view the results. You can use it to test the effect of changing settings on the published output. If you determine that the test settings produce undesirable results, you can restore the Factory Default publish settings by selecting it from the Publish settings drop down list.

    • User Default

      The MathWorks installs this named set of publishing properties in anticipation that you will have a set of publish properties that are common to most or all of your publishing configurations. Initially, User Default settings are identical to those in the Factory Default. See Creating a Template for Typical Publish Settings for an example of changing the User Default settings to best suit your publishing needs.

  7. In the Settings Name field, enter a meaningful name for the settings. For example, reduce_image. Then click Save.

    You can now use the reduce_image publish settings with other publish configurations.

    You can also overwrite the publishing properties saved in an existing publish settings name by selecting it from the Publish settings drop-down list, and then clicking Overwrite. However, you cannot overwrite the Factory Default publish settings.

      Note   When you overwrite a publish settings name, configurations that currently specify that publish settings name do not have their publish properties updated to use the new settings. Instead, their properties that now have different values from the updated publish settings are marked with a dot.

  8. In the Edit M-File Configurations dialog box, do one of the following:

    • Click Publish to publish the M-file that is open in the Editor using the new settings.

    • Click Close to close the dialog box.

Specifying Values for the Publish Settings Property Table

The sections that follow describe each of the publish settings properties that you can adjust to fit your needs when you create or update a publish configuration. To access a publish configuration open the M-file for which you want create or update a publish configuration, and then select File > Publish Configuration for file name > Edit Publish Configurations for file name.

You can set or adjust values for the following properties:

Output file format.   Select one of the choices from the drop-down list to publish the document to one of the following file formats:

MATLAB names the published file with the same name as the publish configuration that produced it and stores it, along with images that MATLAB generates from M-file code, in the folder specified with the Output folder property.

Output folder.   Type the full path of the folder to which you want MATLAB to publish the output document and its associated image files. For example, if your M-file is in I:\my_matlab_files\my_mfiles, you might specify I:\my_matlab_files\my_word_files if you are creating a publish configuration for documents that you publish to Word.

XSL file.   Type the full path of the Extensible Stylesheet Language (XSL) file, that you want to use when you specify the Output file format as HTML, XML, or LaTeX. If you leave this field blank, MATLAB uses a default stylesheet which is installed with the MATLAB software.

Figure capture method.   Specify a figure capture method to indicate how you want figures and dialog boxes that the M-file code creates to appear in published documents.

The following list provides some suggestions on how to set this property, depending on the type of document you are publishing. (The document shown in the images that follow was published with the Max image width property set to 150 pixels.)

The following table summarizes the effects of the various Figure capture methods.

Use this Figure Capture MethodTo Get Figure Captures with these Appearance Details
 Window DecorationsPlot Backgrounds

entireGUIWindow

Included for dialog boxes; Excluded for figuresSet to white for figures; matches the screen for dialog boxes

print

Excluded for dialog boxes and figuresSet to white

getframe

Excluded for dialog boxes and figuresMatch the screen plot background

entireFigureWindow

Included for dialog boxes and figuresMatch the screen plot background

Image format.   Select the file type for images produced when publishing M-files. The image file types available in the drop-down list depend on the Figure capture method you specify.

Use new figure.   Set to true if you want MATLAB to create a new Figure window with a white background and at the default size before publishing if the M-file code generates a figure. After publishing finishes, MATLAB closes the Figure window.

To use a figure with different properties for publishing, set this property to false. Then open a Figure window, change the size and background color, for example, and then publish. Figures in your published document use the characteristics of the figure you opened before publishing.

The following example demonstrates how to specify new Figure window properties for published images by setting the Use new figure publish settings property to false:

  1. Create sine_wave_f.m, as described in Creating a Publish Configuration for an M-File.

  2. Create a Figure window by saving the following code in an M-file and then running it:

    function createfigure
    %CREATEFIGURE
    
    % Create figure
    figure1 = figure('Name','purple_background',...
    'Color',[0.4784 0.06275 0.8941]);
    colormap('hsv');
    
    % Create subplot
    subplot(1,1,1,'Parent',figure1);
    box('on');
    
    % Create xlabel
    xlabel({''});
    
    % Create title
    title({''});
    

    The following figure appears.

    Image of Figure Window with purple background.

  3. Reduce the size of the figure by dragging and dropping the edges. For example:

    Image of Figure Window with purple background as shown in the previous image, but about one-third of the size.

  4. Do not close the window.

  5. Make sine_wave_f.m the active file in the Editor, and then select File > Publish Configurations for sine_wave_f.m > Edit Publish Configurations for sine_wave_f.m.

  6. In the Publish settings drop-down list, select Factory Default.

  7. If you have previously set Publish settings for sine_wave_f.m, the Change Publish Settings dialog box opens. Click Change to Factory Default.

  8. In the Publish settings properties table, set Use new figure to false.

  9. Click Publish. MATLAB publishes sine_wave_f.m as shown in the following figure.

    Image of Web Browser with the small Figure Window presented in the previous image included.

Max image width.   Overwrite the current value to restrict the width of images in the published output. Note the following about this property:

Max image height.   Overwrite the current value to restrict the height of images in the published output. Note the following about this property:

Create thumbnail.   Set to true to direct MATLAB to create a thumbnail image if the Image Format preference is a bitmap, such as .png or .jpg. For example, you can use this thumbnail to represent your M-file in HTML pages. If you create your own demos and include them in the Help browser Demos pane via a demos.xml file, MATLAB automatically creates a list of your demos that includes the thumbnail for each.

Set to false to direct MATLAB to not create a thumbnail image.

Include code.   Set to true to have MATLAB include the M-file code in the published document. Set to false to the have MATLAB exclude the code from all output file formats except HTML. When the output file format is HTML, MATLAB inserts the M-file code in the output file as an HTML comment. Therefore, when viewed in a Web browser, for example, the M-file code is not displayed.

Use the MATLAB grabcode function if you want to extract the M-file code from the published HTML file.

For example, suppose you publish I:/my_matlabfiles/my_mfiles/sine_wave_f.m to HTML using a publish configuration with the Include code property set to false. If you share the published document with colleagues, they can view the published document in a Web browser. If your colleagues want to see the M-file code that generated the published document, they can issue the following command from the folder containing sine_wave_f.html:

grabcode('sine_wave_f.html')

MATLAB opens the M-file code that created sine_wave_f.html in the Editor.

See Creating a Publish Configuration for an M-File for the sine_wave_f.m code.

Evaluate code.   Set to true to direct MATLAB to evaluate the M-file code while publishing the results and include the results in the output document.

Set to false, to direct MATLAB to not evaluate the code nor include code results when publishing an M-file.

Because MATLAB does not evaluate the code, there might be invalid code in the M-file. Therefore, you might not want to set this property to false without first running the M-file.

For example, suppose you include comment text, Label the plot, in an M-file, but forget to preface it with the comment character. If you publish the document to HTML, and set Evaluate code to true, the published document includes the error, such as shown in the following figure.

Image of Web Browser which presents M-file code followed by the error message it produces.

Use this property with the Max # of output lines property to specify the maximum number of lines you want to include in the output. This property is helpful when you have code that produces a lot of output and you only want to include a sample of it in the published document.

Catch error.   Set to true to direct MATLAB to publish and include the error message text in the published document if an error occurs when it evaluates the code.

Set to false to direct MATLAB to terminate the publish operation if an error occurs when it evaluates the code.

This property has no effect if you set the Evaluate code property to false.

Max # of output lines.   Type a value to specify the maximum number of output lines that you want to include after each cell break in the published document.

For example, suppose your M-file code includes a loop, such as the following:

for n = 1:100
  disp(x)	
end;

If you publish the document, then by default, all 100 lines of the output generated by the preceding code is included in the published document. If you want to include a smaller representative sample of the output, set Max # of output lines to a small value, such as 10.

Creating a Template for Typical Publish Settings

Use the User Default publish settings installed with MATLAB to create a template for all or most of your publish configurations.

Initially, the User Default publish setting has the same property values as the Factory Default publish settings. Update and save your most commonly used property settings to avoid having to reset the same settings each time you create a new publish configuration.

For example, suppose that you frequently publish your M-files using the factory installed User Default settings, with a few exceptions. You want to change the factory installed User Default settings to:

Update the User Default publish settings, as follows:

  1. If the Edit M-File Configurations dialog box is not already open, click the down arrow on the Publish button , and then click the configuration for which you want to set the properties as described in the preceding list.

  2. From the Publish settings drop-down list, select User Default.

    If the Change Publish Settings dialog box opens, click Change to User Default.

  3. Adjust the values in the publish settings properties table, so that the Publish settings appear as shown in the following figure.

  4. Click Save As.

    The Save Publish Settings dialog box opens.

  5. In the Publish settings drop-down list, select User Default, and then click Overwrite.

    The User Default publish settings are now saved with the specified property values.

Now, suppose you want to create a publish configuration using all the same settings, except you want to publish your M-file to a Microsoft Word document. Follow these steps:

  1. In the Editor, open the M-file that you want to publish to a Word document.

  2. Click the down arrow next to the Publish button on the Editor toolbar and click Edit Publish Configuration for file name, where the file name is the name of the file that you want to publish to a Word document.

    The Edit M-File Configurations dialog box opens.

  3. If you want, adjust the MATLAB expression.

  4. Notice that the Publish settings are set to User Default and the publish settings properties table contains the values you set in the preceding list of steps.

  5. Change the Output file format from html to doc.

  6. Click Save As.

    The Save Publish Settings dialog box opens.

  7. In the Settings name box, type a name for the new group of publish settings. For example, WordDefault.

  8. Click Save.

Now you can use any one of the following publish settings as the basis for new publish settings, for the next publish configuration you create:

Running an Existing Publish Configuration

After creating a publish configuration, you can run the configuration without opening the Edit M-File Configurations dialog box, as follows:

  1. In the Editor toolbar, click the down arrow on the Publish button Publish button , and position the mouse pointer on a publish configuration name. MATLAB displays a Tooltip showing the publish configuration's MATLAB expression so you can see what will be evaluated when you publish the M-file using the named configuration.

    Image of Editor with Publish button menu open and the mouse pointer hovering over sine_wave_f.m. A Tooltip presenting the MATLAB expression for sine_wave_f.m is open.

  2. To use the publish configuration, select a configuration name. MATLAB publishes the M-file using the MATLAB expression you specified in the publish configuration. For example, if you select sine_wave_f, MATLAB sets the value of the input argument, x, to 0:1:6*pi and passes it to the M-file function before evaluating and publishing it. (To see how to set the MATLAB expression, see Creating a Publish Configuration for an M-File.)

Creating Multiple Publish Configurations for an M-File

You can create multiple publish configurations for a given M-file. You might do this to publish the M-file with different values for input arguments, with different publish setting property values, or both. Create a named configuration for each purpose, all associated with the same M-file. Then, any time you publish the M-file, you can chose and run whichever particular publish configuration that you want. For example, for sine_wave_f(x) you might use different values for x and adjust publishing properties for these purposes:

The following sections provide instructions for creating multiple configurations for sine_wave_f.m.

Example of Publishing sine_wave_f.m to Microsoft Word

The following steps provide an example of settings you might use when you want to publish an M-file to Word. This example uses the sine_wave_f.m file, the code for which is presented in Creating a Publish Configuration for an M-File.

  1. Copy sine_wave_f.m to your current folder. If you have write permission to your current folder, you can type the following in the Command Window to copy the file from the MATLAB root directory:

    copyfile(fullfile(docroot,'techdoc','matlab_env','examples', ...
    'sine_wave_f.m'),'.','f')
  2. In the Editor, open sine_wave_f.m.

  3. Select File > Publish Configuration for sine_wave_f.m > Edit Publish Configurations for sine_wave.m.

  4. Select sine_wave_f in the list of M-files and configurations, click the down arrow next to the Add button , and then select Publish Configuration.

    Image of the Edit M-File Configurations dialog box with the Add button menu open. The menu contains two options: Run Configuration and Publish Configuration. Publish Configuration is selected.

    MATLAB creates a new publish configuration, sine_wave_f_n where the value of n depends on the number of publish configurations you have previously created for sine_wave_f.

    Image of the Edit M-File Configurations dialog box with the sine_wave_f_2 publish configuration selected in the left pane.

  5. Rename sine_wave_f_n to sine_wave_word, and replace the default template expression with the following code:

    x = 0:1:rand*pi;
    sine_wave_f(x)
    
  6. Change the values for Publish settings, as follows so that the M-file is published to a Word document, including the code, its output and any errors the code may generate. The maximum values for the image height and width are set so that the images are not cropped in the Word document:

    1. For Output file format, select doc from the drop-down list.

    2. For Image format, select jpeg from the drop-down list.

    3. For Max image width, type 400.

    4. For Max image height, type 400.

  7. Click Publish to test how the settings affect the Word document.

    You can continue to test and change publish settings until you achieve the results that you want.

      Tip   In addition to testing that your M-file code evaluates as expected and publishes to Word as expected, you might run the spelling and grammar checker in Word to be sure that the comments in your M-file do not contain typographical or grammatical errors.

  8. Optionally, if you plan to reuse these publish settings later, click Save As. In the Save Publish Settings dialog box, in the Settings name field, type word_settings, and then click Save.

Steps for Publishing sine_wave_f.m to HTML

These steps provide an example of creating a configuration for sine_wave_f.m, that publishes the M-file to HTML. You might do this to publish output for inclusion in a blog, for example.

  1. Copy sine_wave_f.m to your current folder. If you have write permission to your current folder, you can type the following in the Command Window to copy the file from the MATLAB root directory:

    copyfile(fullfile(docroot,'techdoc','matlab_env','examples', ...
    'sine_wave_f.m'),'.','f')
  2. In the Editor, open sine_wave_f.m.

  3. Select File > Publish Configuration for sine_wave_f.m > Edit Publish Configurations for sine_wave_f.m.

    Select sine_wave_f in the list of M-files and configurations, click the down arrow next to the Add button , and then select Publish Configuration.

  4. Select sine_wave_f in the list of M-files and configurations, click the down arrow next to the Add button , and then select Publish Configuration.

    MATLAB creates a new publish configuration, sine_wave_f_n where the value of n depends on the number of publish configurations you have previously created for sine_wave_f.

    Image of the Edit M-File Configurations dialog box with the sine_wave_f_2 publish configuration selected in the left pane.

  5. In the Publish configuration name field, replace sine_wave_f_n with sine_wave_html.

  6. In the MATLAB expression field, replace the default expression with the following:

    x = 0:1:rand*pi;
    sine_wave_f(x)
    

      Tip   To get a quick view of the expression used in a different configuration, position the mouse pointer on the name of a different publish configuration without selecting it. In the following figure, sine_wave_html is selected, but the mouse pointer is positioned on sine_wave_f. You can see the MATLAB expression specified for the sine_wave_f configuration in the Tooltip.

    Image M-File Configurations dialog box with the cursor hovering over the sine_wav_f  publish configuration. A Tooltip displays the MATLAB Expression for this configuration.

  7. Change the values for Publish settings, as follows so that the M-file is published to an HTML document, including the code, its output and any errors the code may generate. The maximum values for the image height and width are set so that the images are not cropped in the Word document:

    1. For Output file format, select html from the drop-down list.

    2. For Max image width, type 400.

    3. For Max image height, type 400.

  8. Click Publish to test how the settings affect the HTML document.

    You can continue to test and change publish settings until you achieve the results that you want.

  9. Optionally, if you plan to reuse these publish settings later, click Save As. In the Save Publish Settings dialog box, in the Settings name field, type html_settings, and then click Save.

Steps for Publishing sine_wave_f.m to Microsoft PowerPoint

These steps provide an example of creating a configuration for sine_wave_f.m, that publishes the M-file to Microsoft PowerPoint. You might do this to publish output for presentation in a meeting, for example.

  1. Copy sine_wave_f.m to your current folder. If you have write permission to your current folder, you can type the following in the Command Window to copy the file from the MATLAB root directory:

    copyfile(fullfile(docroot,'techdoc','matlab_env','examples', ...
    'sine_wave_f.m'),'.','f')
  2. In the Editor, open sine_wave_f.m.

  3. Select File > Publish Configuration for sine_wave_f.m > Edit Publish Configurations for sine_wave_f.m.

  4. Select sine_wave_f in the list of M-files and configurations, click the down arrow next to the Add button , and then select Publish Configuration.

    MATLAB creates a new publish configuration, sine_wave_f_n where the value of n depends on the number of publish configurations you have previously created for sine_wave_f.

    Image of the Edit M-File Configurations dialog box with the sine_wave_f_2 publish configuration selected in the left pane.

  5. In the Publish configuration name field, replace sine_wave_f_n with sine_wave_ppt.

  6. In the MATLAB expression field, replace the default expression with the following:

    x = 0:1:6*pi;
    sine_wave_f(x)
  7. Assume for the purposes of a PowerPoint presentation, you do not want to include the code.

    Change the Output file format to ppt and Include code to false.

  8. Click Publish to test how the PowerPoint output appears.

  9. Optionally, if you plan to reuse these publish settings later, click Save As. In the Save Publish Settings dialog box, in the Settings name field, type ppt_settings, and then click Save.

Steps for Publishing sine_wave_f.m to PDF

This example uses the sine_wave_f.m file, the code for which is presented in Creating a Publish Configuration for an M-File.

  1. Copy sine_wave_f.m to your current folder. If you have write permission to your current folder, type the following in the Command Window to copy the file from the MATLAB root directory:

    copyfile(fullfile(docroot,'techdoc','matlab_env','examples', ...
    'sine_wave_f.m'),'.','f')
  2. Open sine_wave_f.m in the Editor.

    edit sine_wave_f.m
  3. Select File > Publish Configuration for sine_wave_f.m > Edit Publish Configurations for sine_wave_f.m.

  4. Select sine_wave_f in the list of M-files and configurations, click the down arrow next to the Add button , and then select Publish Configuration.

    MATLAB creates a publish configuration, sine_wave_f_n, where the value of n depends on the number of publish configurations you have previously created for sine_wave_f.

  5. In the Publish configuration name field, replace sine_wave_f_n with sine_wave_pdf.

  6. In the MATLAB expression field, replace the default expression with the following:

    x = 0:1:6*pi;
    sine_wave_f(x)
  7. Change the Output file format to pdf.

  8. Click Publish to test how the PDF output appears.

    Notice that when you publish to PDF, unlike other publishing output formats, the introductory text appears after the table of contents:

  9. Optionally, if you plan to reuse these publish settings later, click Save As. In the Save Publish Settings dialog box, in the Settings name field, type pdf_settings, and then click Save.

About the publish_configurations.m File

When you create one or more publish configurations using the Edit M-File Configurations dialog box, the Editor updates the publish_configurations.m file in your preferences folder. (This is the folder that MATLAB returns when you run the MATLAB prefdir function.)

Although you can port this file from the preferences folder on one system to another, there can only be one publish_configurations.m file on a system. Therefore, you should only do this if you have not already created configurations on the second system. In addition, because this file may contain references to file paths, you need to be sure the specified M-files and paths exist on the second system.

The MathWorks recommends that you not update publish_configurations.m in the MATLAB Editor or a text editor. Changes that you make using tools other than the Edit M-File Configurations dialog box may be overwritten later. Each time you save a configuration using the Edit M-File Configurations dialog box, MATLAB updates the publish_configurations.m file, as well as the run_configurations.m file. For more information, see About the run_configurations.m File.

Finding Publish Configurations

The method you use to find publish configurations is the same as the one you use to find run configurations. For details, see Find Configurations.

Removing Publish Configurations

If you no longer need a publish configuration because you do not use it or because you deleted the M-file with which it is associated, it is a good practice to delete the publish configuration. The method you use to delete publish configurations is the same as the one you use to delete run configurations. For details, see Remove Configurations for details.

Reassociating and Renaming Publish Configurations

Each publish configuration is associated with a specific M-file. If you move or rename the M-file, you need to redefine the association. If you delete an M-file, you might want to delete the associated configurations, or associate them with a different M-file. You might also need to modify the statements in the configurations so they will run. The method you use to reassociate and rename publish configurations is the same as the one you use to reassociate and rename run configurations. See Reassociate and Rename Configurations for details.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS