In this homework problem, and in all subsequent homework problems, you will part
ID: 2079216 • Letter: I
Question
In this homework problem, and in all subsequent homework problems, you will partition your script m-file into sections. There will be one section per problem. Because Homework 1 has two problems, your script m-file for this homework will contain 2 sections 1. Have MATLAB print (to the command window) the following: e in fixed-point notation to seven decimal places (plus anew line) e in exponential (scientific notation with five decimal places (plus anew line) 256 in (signed integer notation (plus a new line) In the above, e is the base of the natural logarithm. MATLAB will generate this number whenever you ask for this: exp (1). With this statement, you are asking for ei.O You will use rintf. You should first read the MATLAB documentation on the function fprintf. Pay particular attention to the formatspec portion of the documentation. (On the fprintf documentation page, click on the formatspec hyperlink.) In this problem you won't be printing to a file, so you won't supply the optional fileID input. If you are familiar with the CMC function printf, you will sce that the MATLAB prin function works in a similar way The purpose of this assignment is for you to practice formatted printing of numbers. You are asked not to print pure literal strings. For example, don't do this: fprintf 2.7182818 n' Don't do this It is true that this statement will produce the desired first line. However, you will no the formatted printing of numbers if you do this. Instead, you will ask MATLAB to print exp (1) using a total of 9 characters, 7 of which will be to the right of the decimal place. (There will also be 1 character to the left of the decimal place and the decimal point, making a total of 9 characters.Explanation / Answer
(1)
>> fprintf('%0.7f ',exp(1))
2.7182818
using of 0.7f format in fprintf command, we can get 7 decimals at right side and 2 at left side including dot.
is uses to print the result in new line
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.