Question

You need to write scripts for all problems. Each script should contain the comments on each line. You also need to publish your scripts to pdf files. 1. (Chapter.1) Store a number with a decimal place in a double variable (the default). Convert the variable to type int32 and store the result in a new variable. (10pts) 2. (Chapter.1) Create a variable ftemp to store a temperature in degrees Fahrenheit F). Convert this to degrees Celsius C) and store the result in a variable ctemp. The conversion factor is C (F-32) 5/9. (10pts) 3. (Chapter.1) What would be the results of the following expressions? Write the script to produce the results. State your reasoning in the comments in your script. (15pts) a, b a c -1 b, 3 a 241 c. (3 2) 1 d. xor (5 <6, 8 >4) 4. (Chapter.1) A chemical plant releases an amount A of pollutant into a stream. The maximum concentration of the pollutant at a point which is a distance x from the plant is: (10pts) A 2 Create variables for the values of A and x, and then for C.Assume that the distance x is in meters. Experiment with different values for x, (e in this case is Eulers number, 2.71828) 5. (Chapter.2) Create a vector x which consists of 20 equally spaced points in the range from -r to +n. Create a y vector which is sin(x). (10pts) 6. (Chapter.2) Find the following sum by first creating vectors for the numerators and denominators: (15pts) Continued on the next page
media%2Fa85%2Fa85b0c78-1811-4f92-a1ad-74
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the code for the first 4 problems:

% Store a number with a decimal place in a double variable (the default).

% Convert the variable to type int32 and store the result in a new variable.

doubleVariable = 34.5678;

intVariable = int32(doubleVariable);

fprintf('%f after converting to int32 will become %d\n', doubleVariable, intVariable);

% Create a variable ftemp to store a temperature in degrees Fahrenheit (F).

% Convert this to degrees Celsius (C) and store the result in a variable

% ctemp. The conversion factor is C = (F - 32) * 5/9.

ftemp = 100;

ctemp = (ftemp - 32) * 5 / 9;

fprintf('100 degrees Fahrenheit is: %f degrees centigrade.\n', ctemp);

% What would be the result of the following expressions? Write the script to

% produce the results. State your reasoning in the comments in your script.

value = 'b' >= 'c' - 1; %This expression results in true, i.e., 1.

%This is because, the ASCII value of 'b' is 66, and that of C is 67,

%And 66 >= 67 - 1 ==> 66 >= 66 will evaluate to true.

fprintf('''b'' >= ''c'' - 1 is: %d\n', value);

value = 3 == 2 + 1; %This expression results in true, i.e., 1.

%This is because, 2 + 1 is 3, and 3 == 3 will evaluate to true.

fprintf('3 == 2 + 1 is: %d\n', value);

value = (3 == 2) + 1; %This expression results in 0 + 1 = 1.

%This is because, (3 == 2) evaluates to false, and false i.e., 0 + 1

%evaluates to 1.

fprintf('(3 == 2) + 1 is: %d\n', value);

value = xor(5<6, 8>4); %This expression results in false, ie., 0

%This is because, 5<6 evaluates to true, i.e., 1, and 8 > 4 evaluates

%to true, and xor(true, true) is false, i.e., 0.

fprintf('xor(5<6, 8>4) is: %d\n', value);

%A chemical plant releases an amount A of pollutant into a stream. The

%maximum concentration of the pollutant at a point which is a distance x

%from the plant is: C = A/x (sqrt(2/(pi*e))).

%Create variables for the values of A and x, and then for C. Assume the

%distance x is in meters. Experiment with different values of x. (e in this

%case is Eulers number, 2.71828).

A = 10;

x = 5 : 10;

C = A./x .* (sqrt(2/(pi*exp(1))));

fprintf('The values of C are: ');

disp(C);

And the output screenshot is:

《 MATLAB Window Help <D < > -g [.] e E 4) 97% E -Tue 21 Mar 20:24 MATLAB R2013a 990.64 MB ANANDA KUMAR THUMMAPUDI a PUBLISH

Add a comment
Know the answer?
Add Answer to:
You need to write scripts for all problems. Each script should contain the comments on each...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT