TestingDocs.com
    Software Testing website
    • Automation
      • Selenium
      • JBehave Framework
    • Tutorials
      • MySQL Tutorials
      • Testlink
      • Maven
      • Git
    • IDEs
      • IntelliJ IDEA
      • Eclipse
    • Flowcharts
      • Flowgorithm
      • Raptor
    • About

    Automation

    Subplots Example in MATLAB

    Introduction

    Subplots allow us to plot multiple charts on the same figure in a grid. The axes are created in tiled positions. We can create subplots using the subplot command. For example,

    subplot(m,n,k)

    divides the figure into m x n  grid and k is the kth subplot in the m x n grid.

    Let’s create subplots for four sample trigonometric functions like:

    • sin(x)
    • cos(x)
    • tan(x)
    • sin(x)*cos(x)

    We will create the four subplots in a 2×2 grid.

    MATLAB Script

    % Subplots Example - www.TestingDocs.com
    % Creates 2x2 subplots
    
    % Create x and y vectors 
    x = linspace(-2*pi,2*pi,100);
    y1 = sin(x);
    y2 = cos(x);
    y3 = tan(x);
    y4 = sin(x).*cos(x);
    
    % Create 4 Subplots
    subplot(2,2,1);
    plot(x,y1);
    xlabel('x - axis')
    ylabel('y - axis')
    title('sin(x) plot');
    grid on;
    
    subplot(2,2,2);
    plot(x,y2);
    xlabel('x - axis')
    ylabel('y - axis')
    title('cos(x) plot');
    grid on;
    
    subplot(2,2,3);
    plot(x,y3);
    xlabel('x - axis')
    ylabel('y - axis')
    title('tan(x) plot');
    grid on;
    
    subplot(2,2,4);
    plot(x,y4);
    xlabel('x - axis')
    ylabel('y - axis')
    title('sin(x)*cos(x) plot');
    grid on;

    Subplots in MATLAB

    Related Posts

    Automation /

    Dart return Statement

    Emma Tool

    Automation /

    Code Coverage Tools

    Selenium 4 Automation Project

    Automation /

    Selenium 4 Project Setup on Ubuntu Linux

    Testing webpage mobile-friendliness using a tool

    Automation /

    Testing webpage mobile-friendliness using a tool

    Errors Code Testing Development

    Automation /

    Error Severity Metrics

    ‹ Download and Install Octave on Windows 10› Calculator JUnit Tests in Maven Project

    Recent Posts

    • ChatGPT Plans Free and PlusChatGPT Subscription Plans
    • Stellar Converter for Database ToolStellar Converter for Database
    • Stellar MySQL Log AnalyzerStellar Log Analyzer for MySQL
    • Stellar Repair for MySQLStellar Repair for MySQL
    • ChatGPT IntroductionChatGPT Capabilities
    • How to secure your SQL Database: Tips and Tricks
    • ChatGPT4 Conversational AI FeaturesChatGPT4 Conversational AI Features
    • Trends in Software EngineeringShaping the Future of Development: Exploring Key Trends in Software Engineering
    • Java PerformanceImproving Java Performance with Multithreading
    • QDrant Vector DatabaseOpen-source Vector Databases
    • Difference between PHP and JavaScript?
    • Bing AI Browser Web ContentBing Conversation Styles
    • ChatGPT PreviewChatGPT Introduction
    • Open Source AI Frameworks TensorFlowOpen Source AI Frameworks
    • Artificial Intelligence Tools

    Back to Top

    Links

    • Contact
    • Privacy Policy
    • Cookie Policy

    www.TestingDocs.com