filmov
tv
MATLAB Theory for The disp Command, and The input & fprintf Command ||CBCS Mathematics|| Lecture 9

Показать описание
This lecture contains the following topics:
The disp Command
The input & fprintf Command
_____________________________
The disp command is used to display the elements of a variable without displaying the name of the variable, and to display text. The format of the disp command is:
disp(name of a variable); or disp(’text’);
ar = [5 7 2 4]; disp(ar)
5 7 2 4
disp(’text’);
text
The variable is defined in the script file, and when the file is executed, the user is prompted to assign a value to the variable in the Command Window.
variable_name = input(‘Enter the value of variable:’);
The fprintf command can be used to display output (text and data) on the screen. 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.
fprintf(’text’)
fprintf(‘\n or \t text %3.4f additional text’,variable_name);
_____________________
OTHER LECTURES
____________________
#cbcsmath
#matlabProgramming
#numericalPractical
Contact me:
The disp Command
The input & fprintf Command
_____________________________
The disp command is used to display the elements of a variable without displaying the name of the variable, and to display text. The format of the disp command is:
disp(name of a variable); or disp(’text’);
ar = [5 7 2 4]; disp(ar)
5 7 2 4
disp(’text’);
text
The variable is defined in the script file, and when the file is executed, the user is prompted to assign a value to the variable in the Command Window.
variable_name = input(‘Enter the value of variable:’);
The fprintf command can be used to display output (text and data) on the screen. 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.
fprintf(’text’)
fprintf(‘\n or \t text %3.4f additional text’,variable_name);
_____________________
OTHER LECTURES
____________________
#cbcsmath
#matlabProgramming
#numericalPractical
Contact me:
Комментарии