Question
Recitation 12 On MATLAB 1. [Submit on zyLabs] MATLAB, and other programming languages, are useful for approximating equations that we do not know how to
Recitation 12
On MATLAB 1. [Submit on zyLabs] MATLAB, and other programming languages, are useful for approximating equations that we do not know how to calculate easily. This is especially true with equations that contain integrals and derivatives known as differential equations.
Write a function that takes two arrays as inputs, x and y, and returns an array dydx that is the approximate derivative of y with respect to x. To check your answer, you can plot the approximate derivative with respect to an analytical derivative. In the plot below, we use y = x3, which has the derivative y = 3*x2. This will require you to create an appropriate set of x-axis coordinates for your approximate derivative. Scatter plot your approximate derivative (the output of your function) on the same set of axes as your numerically analytical derivative. You your answer is correct if you have a line with dots running along it, as the approximate derivative should be more or less on top of your original derivative.
2.) [Submit on zyLabs] Write a function that takes three inputs, an array of pressure values P, an array of temperature values T, and an array for different numbers of moles of gas N to create a pressure/temperature/volume plot for. Your function should return a cell array with N elements. Each element in the cell should be a length(P) x length(T) matrix, where each element is the volume for the given pressure, temperature, and number of moles: ??(??,??) = (???????????? ???? ??????????) ? ?? ? ??(??) / ??(??) Note that the Number of Moles is the current index of N. This ends the code you must submit on zyLabs Now create a mesh plot of each PVT relationship you calculated [mesh(temperature, pressure, volume)].
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started