Plotting: Concentrations, curve fitting, 3D Gaussian plot | Matlab Examples

Matlab Tutorials | Examples

Practice 12:

Plotting: Concentrations, curve fitting, 3D Gaussian plot

Create the three plot windows detailed below using the data in the file practice12data.mat.
Your plots should match the provided sample outputs. Pay attention to titles, x-y labels, grids, legends and their positions, colours etc. Running your main script should produce all three plots, in separate windows. You can start new figure windows by giving the commanding figure.
Figure 1

In the structure array named reaction, you can find the time and concentration measurements for the chemical reaction


Create the two plots shown below within a figure window.


The plot at the top should show the molecule concentration of the three components of the reaction versus time.
The plot at the bottom should show the reaction rate versus time, where this rate is calculated using:


Figure 2

In the structure array named icecream, temperature and total ice-cream sales for arbitrary days are saved.
Plot sales versus temperature, using dots with marker size of 20.
Then find the first order polynomial that best fits this data and plot it on top of the previous plot. Using the coefficients of this polynomial, come up with an approximate equation between temperature and sales, and use this equation as the title of the plot. In the title, you can round values to the nearest integers.


Figure 3

Write a function named gaussian2d that gets four variables from its caller in its parameter list:

  • Matrix containing the x-values of the grid
  • Matrix containing the y-values of the grid
  • The mean vector μ containing [μx, μy]
  • The standard deviation vector σ containing [σx, σy]

The function should evaluate the below 2-dimensional Gaussian distribution function for the given x and y grid matrices. The result will be a matrix containing the z-values. This matrix must be returned to the caller program.


In your main program, create the 50×50 X and Y grid matrices in the interval [-1,1]. Call your gaussian2d function twice to get two surface matrices Z1 and Z2. The parameters for Z1 and Z2 (other than the X and Y grid matrices) are as follows:

In the third figure window, plot the surface Z = Z1 + Z2. Use colormap jet and view it from azimuth 45° and elevation 70°.

Files: https://drive.google.com/drive/folders/1jM_HZDhz2_V7V03T1PjWXCT-MFwm4X7N?usp=sharing

Solution:

 

 

One thought on “Plotting: Concentrations, curve fitting, 3D Gaussian plot | Matlab Examples

Leave a Reply

Your email address will not be published. Required fields are marked *