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 6360837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:41:57+00:00 2026-05-24T23:41:57+00:00

I am trying to plot sequences, I have written a function function show_seq(seq) plot

  • 0

I am trying to plot sequences, I have written a function

function show_seq(seq)
 plot (seq)
end

I now want to overload this show_seq to show 2 sequences something like

function show_seq(seq1, seq2)
  plot(seq1,'color','r');
  plot(seq2, 'color', 'b');
end

but this does not work, does anyone have idea about how to overload functions in MATLAB?

  • 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-05-24T23:41:58+00:00Added an answer on May 24, 2026 at 11:41 pm

    You can overload one of your own functions if you put the overloading function in a path that with higher precedence. For more details on path precedence, see this question.

    However, in your case, the easiest would be to modify show_seq so that it accepts multiple optional inputs:

    function show_seq(varargin)
      hold on %# make sure subsequent plots don't overwrite the figure
      colors = 'rb'; %# define more colors here, 
                     %# or use distingushable_colors from the
                     %# file exchange, if you want to plot more than two
    
      %# loop through the inputs and plot
      for iArg = 1:nargin
          plot(varargin{iArg},'color',colors(iArg));
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following data set that I am trying to plot with ggplot2,
I have a plot (sample code pasted below) that I am trying to add
I have one y variable, which I am trying to plot against two related
I'm trying to understand how to have more than one series on a plot,
I'm trying to write a function that plots a ggplot facet_wrap plot over multiple
I'm trying to plot two non-intersecting touching circles, but I think I'm missing something
I have the following problem when trying to plot some 3D data in Mathematica.
I have a frequency distribution I am trying to plot in R. The dataset
I'm trying to plot a graph in matplotlib using numpy and meshgrid. I want
I'm trying to plot some arrows using matploblib with the quiver function. But I

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.