Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8669639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:31:32+00:00 2026-06-12T18:31:32+00:00

I am new to Matlab and I think this is a very basic question..

  • 0

I am new to Matlab and I think this is a very basic question..

I have two arrays:

 tst

  ans =

          0         0    0.2500    0.2500         0         0         0         0

 prp

    ans =

          0         0         0    0.5333    0.0333    0.0333    0.1667    0.0667

I want to plot the averages between those two on the same plot (as a line). What is the best way to do it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:31:33+00:00Added an answer on June 12, 2026 at 6:31 pm

    I usually do something like:

    # Plot figure
    plot(...);
    
    # Calculate the average
    avg = mean(tst);
    
    # Add a line to the figure
    line(xlim(), [avg avg]);
    

    And repeat for prp. You can style the lines however you want according to the linespec documentation.

    Note that you should do this at the end of anything that would change the xlimits (holding and plotting something else, etc.) as it depends on xlim().

    Edit

    I may have misunderstood your question. The above code will plot a horizontal line at the average of the points in the array tst.

    If instead you want a line plot whose points are the average of the two arrays, you want something like:

    # Calculate average between arrays
    avg = mean([tst;prp]);
    
    # Plot all 3 lines at once
    plot([tst;prp;avg]');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am completely new to MATLAB.This may be a rather basic question. Given numerical
Apologies if this is a stupid question, I'm relatively new to Matlab. I've got
I`m absolutely new in Matlab, so I think it is a dumb question, but
I am fairly new to Matlab and have a few questions. I got two
I am relatively new to Matlab and have a question about creating a logical
I am new to Matlab and I am having some trouble. I have two
I'm very new to matlab and am more of an ArcGIS user but I'd
Sorry for the simplicity of the question. New to Matlab and despite its thorough
Question about subclassing in matlab, under the new class system. I've got class A
I thought that latest Matlab does this automatically. I have tested the following exe

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.