How to plot MATLAB contour plots for a variable z dependent on x and y variables

In summary, to plot a graph in MATLAB, you need to create a matrix with the data, assign the variables for heights and humidity values, use the plot command, and optionally convert the dates and times using the datetime function and add a title using the title command.
  • #1
mzalikhan
1
0
Hi all

I am trying to do a MATLAB plot, just like the one attached.

DATA: Graph shows a parameter (suppose) humidity along the height from ground upto 6 Km. Instrument measures humidity at each 30 meter height from the ground. Sample is repeated after each 15 minutes.

DATA FORMAT: Data is in CSV format. First column has Data and time (in same column). First row has heights (in intervals of 30). rest of the matrix is filled with humidity values.

Sample data is attached.

I am currently stuck at importing date into MATLAB.

Please see if you can help.

Best regards
 

Attachments

  • graph.png
    graph.png
    25.4 KB · Views: 502
  • Graph_sample_data.txt
    9.1 KB · Views: 431
Physics news on Phys.org
  • #2
The following steps can help you in plotting the graph: 1. Create a matrix with the data from the csv file. 2. Assign the heights to one variable and the humidity values to another variable. 3. Use the plot command (e.g. plot(x,y) where x is the variable containing the heights and y is the variable containing the humidity values) to create the graph. 4. If necessary, you can use the 'datetime' function (e.g. datetime(A), where A is the variable containing the dates and times) to convert the dates and times into MATLAB format. 5. You can also use the 'title' command to add a title to your graph.
 

Related to How to plot MATLAB contour plots for a variable z dependent on x and y variables

1. How do I create a contour plot in MATLAB?

To create a contour plot in MATLAB, you can use the contour function. This function takes in three arguments: the x and y variables, and the variable z that you want to plot. For example, if your variables are stored in arrays called x, y, and z, you can use the command contour(x, y, z) to create a contour plot.

2. How do I specify the number of contour levels in a MATLAB contour plot?

To specify the number of contour levels, you can use the contour function's optional fourth argument, which specifies the number of levels you want to plot. For example, if you want 10 contour levels, you can use the command contour(x, y, z, 10).

3. How do I change the color scheme of a MATLAB contour plot?

To change the color scheme of a contour plot in MATLAB, you can use the colormap function. This function takes in a colormap name or a custom RGB matrix as an argument. For example, to use a grayscale colormap, you can use the command colormap(gray).

4. How do I add labels and a colorbar to a MATLAB contour plot?

To add labels and a colorbar to a contour plot in MATLAB, you can use the clabel and colorbar functions, respectively. The clabel function adds labels to the contour lines, while the colorbar function adds a colorbar to the plot. Both functions take in the contour plot as an argument.

5. How do I save a MATLAB contour plot as an image?

To save a MATLAB contour plot as an image, you can use the saveas function. This function takes in the figure handle and the filename or file format as arguments. For example, to save the contour plot as a PNG image, you can use the command saveas(gcf, 'my_contour_plot.png').

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
6K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
882
  • Calculus and Beyond Homework Help
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
43K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
Back
Top