What is the output of the following line of code? [code] t=0:pi/8:4pi;[/code]

Quốc Ân

New member
What is the output of the following line of code?
Code:
			t=0:pi/8:4pi;
A. No output as we’ve closed the line of code with a semi-colon
B.
1 2 3 4 5 6 7 8 9
0 1.5708 3.1416 4.7124 6.2832 7.8540 9.4248 10.9956 12.5664
C. Error: Unexpected MATLAB expression
D. Undefined function or variable ‘pi’
 
Answer: c
Explanation: Multiplying an integer with a variable which contains a constant value requires the use of ‘*’. So 4pi should be ‘4*pi’. ‘pi’ is predefined in MATLAB as 3.1416.
 

Tìm kiếm

Back
Top