matlab 2

matlab 2 - a. The following fprintf command: fprintf('First...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
(b) fprintf('\nThe sum is:\n%f \n',sum); Answer: The sum is: 5.700000  (c) fprintf('\nThe sum\nof two numbers is:\n%f \n',sum); Answer: The sum of two numbers is: 5.700000  Help Information: The  fprintf  command can be used to display output (text and data) on the screen or to save it to a  file. With this command (unlike with the disp command) the output can be formatted. For example,  text and numerical values of variables can be intermixed and displayed in the same line. In addition,  the format of the numbers can be controlled.  With many available options, the fprintf command can be long and complicated. The following  examples will not show how to use the fprintf to save the output to a file. 
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: a. The following fprintf command: fprintf('First line of text. Second line of text. Third line of text.'); displays the following text in the Matlab command window: First line of text. Second line of text. Third line of text. The fprintf does not automatically start a new line, and it does not end with a new line. b. With fprintf command it is possible to start a new line in the middle of the text string. This is done by inserting \n before the character that will start the new line. The following fprintf command: fprintf('First line of text. \nSecond line of text. \nThird line of text.\n');...
View Full Document

This note was uploaded on 04/21/2010 for the course CHE 2160 taught by Professor Cygan during the Fall '09 term at LSU.

Page1 / 2

matlab 2 - a. The following fprintf command: fprintf('First...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online