hi,I wanted to know,if it is possible to plot some data in the same graph from two different M files?

1 view (last 30 days)
I want to plot figures in the same graph from two different M-files? Is it possible?

Accepted Answer

dpb
dpb on 29 Jun 2016
Sure. See
doc hold % 'on' after first to add to it
Of course, it the two m-files are user-belligerent and do things like 'close all' or create new figures then you'll have to go through some other gyrations to obtain the second dataset to add...
But, we can't tell what precisely would be required without more details than are given here...
  2 Comments
nafila aytija
nafila aytija on 29 Jun 2016
I am sorry,I have no idea what user belligerent m-file is.The thing I am trying to do is to plot the (BER) curve from two different systems written in two different m-files? I tried with by not clearing the variables but it did not help.How can I do that?
dpb
dpb on 29 Jun 2016
"user belligerent" is the opposite of "user friendly" -- if the m-files are written where they don't consider the present state of the workspace and do things simply for their own convenience (like close all or make a new figure for their output instead of returning the data) then that's not conducive to doing something different that you're wanting to do.
Again, specifically, would need to know details beyond what are given; if you can return the necessary data from one or the other of the two m-files then you can use
hold on
plot(2ndMfileX,2ndMfileY)
on that figure axes to make the second line. If you can't get that data directly, you can do things like retrieve the 'XData','YData' properties from the second figure and use it to plot on the first. Or, there's copyobj that lets you get an element from one figure and make a copy of it in another.
But, what's the simplest is all dependent upon what we don't know which is what you have available to work from as a starting point.
Or, there's the possibility of writing another m-file that takes the necessary pieces from each of these two and melds them together if they're not the same...

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!