Merging Two Graphs into One in Matlab

In summary, to merge two graphs into one in Matlab, you can make your functions return a vector and then plot both vectors on one graph using the "plot" function. Alternatively, you can use the "hold on" and "hold off" commands to plot both graphs on the same figure.
  • #1
Firben
145
0
Hello

Well since I'm a beginner in Matlab i have a question aboute ploting the graph. How can I merge two graphs into one ? Since i have function test(x,h) and function test2(x,h) both of them plotts in a two separate graphs. How do i do if i want to see both of them in a single graph ?

Regards

Carl F
 
Physics news on Phys.org
  • #2
One way is to make your functions return a vector rather than just plotting it. Then it would be something like:

y1 = test1(x,h)
y2 = test2(x,h)
plot(x,y1,x,y2)
 
  • #3
This will also plot them on one graph:

plot(x,y1)
hold on
plot(x,y2)
hold off
 

Related to Merging Two Graphs into One in Matlab

What is the purpose of merging two graphs into one in Matlab?

Merging two graphs into one in Matlab allows for easier comparison and analysis of data. It combines the information from two separate graphs into a single graph, making it easier to identify patterns and trends.

How do I merge two graphs into one in Matlab?

To merge two graphs into one in Matlab, you can use the "hold on" command to plot the second graph on top of the first one. Alternatively, you can use the "plotyy" function, which creates a graph with two y-axes, to plot both graphs on the same figure.

Can I customize the appearance of the merged graph in Matlab?

Yes, you can customize the appearance of the merged graph in Matlab. You can change the line colors, styles, and markers, as well as the axes labels, titles, and legends. This allows you to create a visually appealing and informative graph.

Is it possible to merge more than two graphs into one in Matlab?

Yes, it is possible to merge more than two graphs into one in Matlab. You can use the same methods mentioned above for merging two graphs, but you will need to repeat the steps for each additional graph you want to include in the merged graph.

Are there any limitations to merging graphs in Matlab?

One limitation of merging graphs in Matlab is that the x-axes of the individual graphs must be the same. If the x-axes are different, you will need to adjust the data before merging the graphs. Additionally, if the graphs have different scales, the data may not be visually comparable and may require additional manipulation.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
32
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
313
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
507
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
14
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
Back
Top