Sum of numbers using matlab
To find the sum of two numbers in MATLAB, simply use the addition operator (+) between the two numbers you want to add; for example, to add the numbers 5 and 3, type
5 + 3
in the command window, which will output the result, 8.
Example:
Code
num1 = 10;
num2 = 5;
sum = num1 + num2; % This will calculate the sum of num1 and num2
disp(sum); % This will display the result, which is 15
Key points:
- Basic syntax:
variable = number1 + number2
- Direct calculation: You can directly type the addition operation in the command window without assigning variables