Plotting two curves on the same graph in VS .NET

Generation QR-Code in VS .NET Plotting two curves on the same graph

Plotting two curves on the same graph
Quick Response Code Encoder In VS .NET
Using Barcode encoder for .NET Control to generate, create QR-Code image in .NET framework applications.
Quick Response Code Scanner In Visual Studio .NET
Using Barcode decoder for .NET Control to read, scan read, scan image in VS .NET applications.
MATLAB Demysti ed
Printing Barcode In .NET Framework
Using Barcode generator for Visual Studio .NET Control to generate, create bar code image in Visual Studio .NET applications.
Bar Code Recognizer In .NET
Using Barcode scanner for VS .NET Control to read, scan read, scan image in Visual Studio .NET applications.
Figure 3-10 Using a dotted line to represent f(t) = e t and a dashed line to represent g(t) = e 2t
QR Code Generator In Visual C#
Using Barcode printer for Visual Studio .NET Control to generate, create Quick Response Code image in .NET framework applications.
Encode QR-Code In .NET Framework
Using Barcode generator for ASP.NET Control to generate, create QR Code 2d barcode image in ASP.NET applications.
Dash-dot line - Dotted line : Let s generate the same graph as in Figure 3-9 making the curve f(t) = e t appear with a dotted line The command is
Draw Denso QR Bar Code In Visual Basic .NET
Using Barcode maker for Visual Studio .NET Control to generate, create QR Code image in Visual Studio .NET applications.
Draw USS Code 39 In Visual Studio .NET
Using Barcode drawer for VS .NET Control to generate, create Code39 image in .NET applications.
plot(t,f,':',t,g,'--')
Printing Bar Code In .NET Framework
Using Barcode drawer for .NET Control to generate, create bar code image in VS .NET applications.
EAN 13 Maker In .NET Framework
Using Barcode printer for .NET framework Control to generate, create GS1 - 13 image in Visual Studio .NET applications.
This generates the plot shown in Figure 3-10 If you want to plot all curves using solid lines and simply differentiate them by their colors, just leave off the character string specifying the curve type The plot will be generated using solid lines, which is the default
Painting Barcode In Visual Studio .NET
Using Barcode generation for VS .NET Control to generate, create barcode image in Visual Studio .NET applications.
MSI Plessey Maker In Visual Studio .NET
Using Barcode encoder for VS .NET Control to generate, create MSI Plessey image in .NET applications.
Adding Legends
Drawing EAN 13 In .NET
Using Barcode generator for ASP.NET Control to generate, create EAN-13 image in ASP.NET applications.
Barcode Printer In Visual C#.NET
Using Barcode encoder for .NET framework Control to generate, create barcode image in .NET framework applications.
A professionally done plot often has a legend that lets the reader know which curve is which In the next example, let s suppose that we are going to plot two potential energy functions that are defined in terms of the hyperbolic trig functions sinh(x) and cosh(x) for 0 x 2 First we define x:
ECC200 Maker In Objective-C
Using Barcode encoder for iPad Control to generate, create Data Matrix image in iPad applications.
Bar Code Encoder In Visual Basic .NET
Using Barcode creator for Visual Studio .NET Control to generate, create bar code image in .NET applications.
>> x = [0:001:2];
UPC A Decoder In Visual Basic .NET
Using Barcode decoder for Visual Studio .NET Control to read, scan read, scan image in .NET applications.
Matrix 2D Barcode Drawer In .NET Framework
Using Barcode printer for ASP.NET Control to generate, create Matrix Barcode image in ASP.NET applications.
CHAPTER 3 Plotting and Graphics
Create Code-128 In Java
Using Barcode encoder for Java Control to generate, create Code 128A image in Java applications.
UCC - 12 Creator In Objective-C
Using Barcode drawer for iPhone Control to generate, create UPC Code image in iPhone applications.
Now we define our two functions There is nothing magical about calling a function y or anything else in MATLAB, so let s call the second function z So we have
>> y = sinh(x); >> z = cosh(x);
The legend command is simple to use Just add it to the line used for the plot(x, y) command and add a text string enclosed in single quotes for each curve you want to label In our case we have:
legend('sinh(x)','cosh(x)')
We just add this to the plot command For this example, we include x and y labels as well, and plot the curves using a solid line for the first curve and a dot-dash for the second curve:
>> plot(x,y,x,z,'-'),xlabel('x'),ylabel('Potential'),legend('sinh(x)','cosh(x)')
The plot that results is shown in Figure 3-11 The legend didn t originally show up where it is in the figure, and it probably won t do so on your system either To move the legend to a more favorable position that might be better for printing or display, just hold the mouse pointer over the legend and drag it to the location where you want it to display
Figure 3-11
A plot of two curves that includes a legend
MATLAB Demysti ed
Setting Colors
The color of each curve can be set automatically by MATLAB or we can manually select which color we want This is done by enclosing the appropriate letter assigned to each color used by MATLAB in single quotes immediately after the function to be plotted is specified Let s illustrate with an example Let s plot the hyperbolic sine and cosine functions again This time we ll use a different interval for our plot, we will take 5 x 5 So we define our data array as
>> x = [ 5:001:5];
Now we redefine the functions Remember if we don t do this and we re in the same session of MATLAB, the program is going to think that the functions are defined in terms of the previous x we had used So now we type:
>> y = sinh(x); >> z = cosh(x);
Now we will generate the plot representing y with a red curve and z with a blue curve We do this by following our entries for y and z in the plot function by the character strings r and b respectively The command looks like this:
>> plot(x,y,'r',x,z,'b')
Try this on your own system to see the plot it generates Now, it is possible to set more than one option for each curve So let s use the colors red and blue for the curves, and set the cosh function (the blue curve) to draw with a dashed line This is done in the following way, enclosing all of the plot options for the selected curve within the same set of quotes:
>> plot(x,y,'r',x,z,'b--')
This gives us the plot shown in Figure 3-12 You can t see it in the black and white image, but the dashed line prints on screen as a blue curve MATLAB gives the user eight basic color options for drawing curves These are shown with their codes in Table 3-1
Copyright © OnBarcode.com . All rights reserved.