Untitled
unknown
plain_text
10 months ago
1.1 kB
11
Indexable
1
A = [1 2 3; 4 5 6; 7 8 9];
B = A.^2;
disp('Original Matrix A:')
disp(A)
disp('Matrix after element-wise power 2:')
disp(B)
2
a1 = [1 2 3; 4 5 6; 7 8 9];
s1 = [1 0 3; 2 5 7; 9 8 9];
disp('Matrix a1:')
disp(a1)
disp('Matrix s1:')
disp(s1)
disp('a1 == s1:')
disp(a1 == s1)
disp('a1 <= s1:')
disp(a1 <= s1)
disp('a1 >= s1:')
disp(a1 >= s1)
disp('a1 & s1:')
disp(a1 & s1)
disp('a1 | s1:')
disp(a1 | s1)
3
r = input('Enter the radius of the circle: ');
area = pi * r^2;
disp(['The area of the circle is: ', num2str(area)])
4
str = input('Enter a string: ','s');
revStr = str(end:-1:1);
disp(['Reversed string: ', revStr])
5
nums = input('Enter a list of numbers inside [ ]: ');
avg = mean(nums);
disp(['The average of the entered numbers is: ', num2str(avg)])
6
A = [1 5 3; 7 2 9; 4 6 8];
maxValue = max(A(:));
disp('The matrix is:')
disp(A)
disp(['The maximum value in the matrix is: ', num2str(maxValue)])
betaEditor is loading...
Leave a Comment