MATLAB LATEST EXAM WITH COMPLETE
SOLUTIONS (A+)
what at the end of the line suppresses the echo - ANSWER ;
how would you make something print - ANSWER fprintf()
how would you say "Print this string" - ANSWER fprintf('Print this string')
how do you make the >> go on another line - ANSWER
if you wanted to print 'My name is Nadia Parsell' and wanted to make sure the >> was on
another line, how would you do that - ANSWER fprintf('My name is Nadia Parsell
')
where can you have the (
) - ANSWER anywhere
if you wanted to print 'First line' 'Second line' and 'Third line' on different lines how would
you do that - ANSWER fprintf('First line
Second line
Third line
')
how do you clear everything in your workspace - ANSWER clear all
, how do you clear the command window - ANSWER clc
if your script is not terminating, how would you manually stop it - ANSWER command +.
how do you create a multi-line comment - ANSWER %{This is a multi-line comment %}
How would you prompt the user for values or numbers - ANSWER input()
How would you prompt a user to input a number - ANSWER myNum=input('Enter a
number:')
how would you ask a user to input their age - ANSWER yourAge=input('Please enter
your age:')
By default what will the input be considered as - ANSWER A number
What would you have to do in order to force MATLAB to take the input as a string -
ANSWER Add ','s
how would you ask somebody to enter their name ANSWER yourName=input('Please
enter your name:','s')
when printing number. what is the difference between %d or %f ANSWER %f gives you 6
decimal places, %d just gives you the number you placed in
so if we had to code fprintf('%s %s %s
', 'first', 'second', 'third') how would you reorder it so that it goes from third second to
first - ANSWER fprintf('%3$s %2$s %1$s
SOLUTIONS (A+)
what at the end of the line suppresses the echo - ANSWER ;
how would you make something print - ANSWER fprintf()
how would you say "Print this string" - ANSWER fprintf('Print this string')
how do you make the >> go on another line - ANSWER
if you wanted to print 'My name is Nadia Parsell' and wanted to make sure the >> was on
another line, how would you do that - ANSWER fprintf('My name is Nadia Parsell
')
where can you have the (
) - ANSWER anywhere
if you wanted to print 'First line' 'Second line' and 'Third line' on different lines how would
you do that - ANSWER fprintf('First line
Second line
Third line
')
how do you clear everything in your workspace - ANSWER clear all
, how do you clear the command window - ANSWER clc
if your script is not terminating, how would you manually stop it - ANSWER command +.
how do you create a multi-line comment - ANSWER %{This is a multi-line comment %}
How would you prompt the user for values or numbers - ANSWER input()
How would you prompt a user to input a number - ANSWER myNum=input('Enter a
number:')
how would you ask a user to input their age - ANSWER yourAge=input('Please enter
your age:')
By default what will the input be considered as - ANSWER A number
What would you have to do in order to force MATLAB to take the input as a string -
ANSWER Add ','s
how would you ask somebody to enter their name ANSWER yourName=input('Please
enter your name:','s')
when printing number. what is the difference between %d or %f ANSWER %f gives you 6
decimal places, %d just gives you the number you placed in
so if we had to code fprintf('%s %s %s
', 'first', 'second', 'third') how would you reorder it so that it goes from third second to
first - ANSWER fprintf('%3$s %2$s %1$s