Question

In: Other

What are the restrictions in naming variables and script files in Matlab? What is the difference...

What are the restrictions in naming variables and script files in Matlab?

What is the difference between the operators * and .*

What is the function of the commands help, who, and logspace?

Consider the Van der Waals Equation of State for modeling the P-V-T behavior of gases.

.

Suppose a= 3, b=4, V=5; R=8.3, T=400. Write a Matlab code to compute p.

Solutions

Expert Solution

The information regarding MATLAB is as follows:

1) Restrictions in naming variables and script files:

- The variable names for which a particular value or equation is to be assigned should never be named after the functions in matlab such as add, det, plot etc

- The variable name will be valid if it starts with a letter and followed by digits, letters and underscores.

- The variable name should be under the limits provided by the MATLAB which can be known by the command: " namelengthmax"

- MATLAB is case sensitive. The variable name x and X have huge difference.

- The script files name should never be named after the keywords in MATLAB. such as det, plot, subplot.

-The script files name should never be named after the function which you defined in your MATLAB code.

2) Difference between the operators * and .*

the operator * is used to perform multiplication in MATLAB

the operator .* is used to perform element wise product of the vectors.

If a=[1,2;3,4;5,6] and b=[1,2,3;4,5,6]

c = a*b

= 9 12 15

19 26 33

29 40 51

d = a.*b

= 1 4

9 16

25 36

3)Functions of the commands:

help= It obtains help generally or for a specific function

who= It displays the cuurent workspace variable names which have been used till date.

logspace= It is used for creating frequency vectors i.e, it provides space for 50 variables.

4)MATLAB CODE FOR VAN DER WAAL:

function F= vander(V)

a=3;

b=4;

V=5;

R=8.3;

T=400;

f= ((R*T)/(V-b))-(a/V^2);

F=[f;V];


Related Solutions

1. What guidelines are to be followed for naming variables? 2. What is the difference between...
1. What guidelines are to be followed for naming variables? 2. What is the difference between a primitive variable and a reference variable? 3. What is meant by the term "Conditionally Executed"? 4. Why is it good advice to indent all the statements inside a set of braces? 5. Describe the difference between pretest loops and posttest loops.
What is the numbering scheme for naming fatty acids and what is the difference between cis...
What is the numbering scheme for naming fatty acids and what is the difference between cis and trans fatty acids? What are the general properities of glycosidic linkages?
MATLAB: Write as a script in the editor window of matlab. Quadratic roots. Write a program,...
MATLAB: Write as a script in the editor window of matlab. Quadratic roots. Write a program, quadroots.m, for finding the roots of the second- order polynomial ax2 + bx + c. Use the quadratic equation. The inputs are the coefficients a,b, and c and the outputs are z1 and z2. The program should produce (exactly) the following output in the Command window when run with (a, b, c) = (1, 2, −3):
a MATLAB script that: • Prompts the user for - a lower-bound for the plot interval...
a MATLAB script that: • Prompts the user for - a lower-bound for the plot interval and stores it in a variable named Lbound - an upper-bound for the plot interval and stores it in a variable named Ubound, and - the number of points at which a function is to be evaluated to generate a plot of the function over the specified range and stores it in a variable named npoints. • Generates a plot of f(x) = x3...
write a matlab script for double mass spring system with animation.
write a matlab script for double mass spring system with animation.
Part A: Write a MATLAB script to find the volume of the cylinder in gallons, as...
Part A: Write a MATLAB script to find the volume of the cylinder in gallons, as well as the tank dimensions in feet. Assume that the initial measurements are 7 meters in diameter and 11 meters tall. Display your final answers to the screen using disp and a statement without a semicolon, e.g. write the following into your script disp(‘The capacity in U.S. gallons is:’), capacity, where capacity is a variable that you defined in preceding calculations. Part B: In...
In this task, you will create a Python script in which you will practice reading files...
In this task, you will create a Python script in which you will practice reading files in Python and writing them to a new output file. Construct a text file called Py4_Task3_input.txt that has the following lines: 4 Sandwiches 04 July 2020 Pasta 31 October 2014 Hot Dogs 15 November 2005 Tacos 25 December 1986 The first line of the file represents the number of lines in the data file. Write a loop that reads in each additional line (one...
3. Write a Matlab script that describes the dynamics of Pressure and Flow in the systemic...
3. Write a Matlab script that describes the dynamics of Pressure and Flow in the systemic arteries and Left Ventricle. Assume that : 1) Pressure in the Left atrium (PLA) and in the Systemic Veins (Psv) remain constant. 2) A time dependent LV compliance 3) Opening/Closing of the heart valves instantaneously with the direction of flow (i.e. valves are at an open or closed states. Use parameter values from the handout.
Using MATLAB or Octave, Write a script that prompts the user for the coordinates of three...
Using MATLAB or Octave, Write a script that prompts the user for the coordinates of three points A, B, and C, namely (xA, yA), (xB, yB), (xC, yC), forming a triangle, storing each in a variable (for a total of 6 variables). The script should then calculate the centroid G = (xG, yG) using xG = xA+xB+xC 3 and yG = yA+yB+yC 3 , storing each in a variable. Finally, the script should print all four points. Sample output: Enter...
Write a bash script to find all the files ending with .c recursively for every directory...
Write a bash script to find all the files ending with .c recursively for every directory in your current working directory, then copy each one to a folder called programs, need handle duplicates by appending the number to the end of the file (ex main.c main-1.c ) compile them and generate a report report should look like: main.c compiles prog2.c failed main-2.c compiles etc.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT