Reference no: EM13742933 , Length: 1
QUESTION 1
Given the following age= [15,17,25,55,76]
Use the find command to list the eligible ages (not the index number) for a standard driver's license. Eligible applicants are at least 18 years old but less than 70 years old.
age(find(age<70 & age>=18))
find(age>=18 & age<70)
find(age<70 & age>=18)
age(find(age>=18 && age<70))
age(find(age>=18 & age<70))
age(find(age>=18 I age<70))
QUESTION 2
What data type (class) is accepted by the fprintf function?
logical
single
char
none of these
double
QUESTION 3
Finish the code:
volume = input('Enter amount of gas: \n')
pick= menu('Measure the gasoline in liters or gallons?','gallons','liters')
switch
factor = 1; unit= 'gallons'
factor = 0.264172;
unit = liters'
%close the switch structure
rate=2.16; %dollars per unit
fprintf('That will be $ %5.2f for %5.1f %s \n', volume*factor*rate, volume, unit)
QUESTION 4
Use [x,y]=gtext(1) to pick many points off a graph with crosshairs and output the coordinates.
True False
QUESTION 5
Use fprintf to output to the command window AND to a text file called approx.txt.
A data dictionary and descriptive comments that show that you understand the program.
QUESTION 6
Create a midpoint break loop. Here's how to organize it.
%Use an infinite while command to begin
%Next, ask the user for input
%Test if the answer is not a positive number
%If their answer is not a positive number, inform them that it must be a positive number
%Otherwise, total up the cost
%Print out the total to a text file
%Break out of the infinite loop
%End the program
1. |
A. else |
2. |
B. if num_candy_bars>0 |
3. |
C. if num_candy_bars<0 |
4. |
D. break |
S. |
E. fid=fopen('bill.txt','w'); fprintf(fid,'The total cost is %S.2f dollars \n',total); fclose(fid); |
6. |
F. end %while loop |
7. |
G. disp('Must be a positive number, try again') |
8. |
H. while n<3 |
9. |
I. while(1) |
10 |
J. num_candy_bars=input('Enter the number of candy bars'); |
|
K. end %if |
|
L. total-num_candy_bars*0.75: |
QUESTION 7
What is the result of the following logical operation and what class is the output? Given x=1:5; y=[-2, 0, 2, 4, 6]; z=8:-1:4;
(z>x I z>y) & x>y
ans=
1 1 1 0 0
ans would belong to the double class ans =
1
1
1
0
0
ans would belong to the double class ans =
1 1 1 0 0
ans would belong to the logical class
QUESTION 8
Turn in yourlastname4.m
Since we are studying repetitive structures this week, make sure you use a loop for this exercise! Please see and adhrere to the attached the directions for this exercise: Homework4 Halev.odf
QUESTION 9
Consider this bit of code.
1 C=[30,55,10];
2 if C<=55
3 disp('G is a small value equal to:')
4 disp(G);
5 end %if
Do lines 3 and 4 execute?
True
False
QUESTION 10
Let's say you have defined a numeric variable, num=10.
What is the command to change a numeric type into a character (or string) type? double(num)
- num2str(num)
- sprintf('Yos ', num)
- char(num)
- fprintf('%s ', num)
- str2num(num)