Select Page

Scope can easily shown you the result of the simuilation. However, it is not clear when the graph from the scope is transfer to the Word document. Here is the step to properly plot graph from Simulink simulation.

  1. Add “To workspace” block into the simulation. [Library>Simulink>Sinks>To Workspace]
  2. Change the variable name according to your specification. Change the “Save format” to “Array”.
  3. Add “Clock” block into the simulation to record the time. [Library>Simulink>Sources>Clock]
  4. Copy the “To workspace” block to the signal you want to plot. Connect the “Clock” to the “To workspace” block.
  5. Run the simulation. All the signals connected to the “To workspace” are now available in the MATLAB Workspace area.
  6. Open a new script in MATLAB.
  7. Copy this code:
    clc;                %To clear command window
    close all;       %To close all figure 

    subplot(2,1,1)            %Use subplot to do multiple plot
    plot(t,Va);                   %Plot Va against t.
                                       %Va and t taken from workspace
    xlabel(‘Time, t (s)’);    %Label x-axis
    ylabel(‘Voltage A, V_a (V)’); %Label y-axis
    grid on;                       %add grid
    xlim([0 5]);                   %change the range of x-axis
    ylim([-0.1 1.1]);           %change the range of y-axis

    subplot(2,1,2)             %Use subplot to do multiple plot

    plot(t,Ia);                     %Plot Ia against t.
                                        %Ia and t taken from workspace
    xlabel(‘Time, t (s)’);     %Label x-axis
    ylabel(‘Current A, I_a (A)’); %Label y-axis
    grid on;                        %add grid
    xlim([0 5]);                  %change the range of x-axis
    ylim([-1.1 1.1]);           %change the range of y-axis

  8. The figure produced by the script is better compared to the scope.
  9. To transfer the figure to the Word document, adjust the figure to the desired size. Then “Edit”>”Copy Figure”. Paste to Word document.