hi,I wanted to know,if it is possible to plot some data in the same graph from two different M files?
조회 수: 2 (최근 30일)
이전 댓글 표시
I want to plot figures in the same graph from two different M-files? Is it possible?
댓글 수: 0
채택된 답변
dpb
2016년 6월 29일
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
dpb
2016년 6월 29일
"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...
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!