matlab Write a script only a very few lines to determine the
matlab
Write a script (only a very few lines) to determine the maximum value and its index of the vector x, and to print out maximum value = ..., index = ... using disp, where \"...\" must be filled in, and the sentence must end with a period. Assume that the matrix F has already been entered into MATLAB, but you don\'t yet know its size. Write the MATLAB code needed to answer each part using disp. Print out The matrix F has ... rows and ... columns. where it is your responsibility to fill in \"...\". Print out The maximum value of F is ... where you must include the dot at the end of this sentence. Print out The sum of the diagonal elements of F is .... where you must include the dot at the end of this sentence.Solution
[a]
A = [1 5 4 ;6 8 9 ;2 1 3];
[v,ind]=max(A);
[v1,ind1]=max(max(A));
disp(sprintf(\'Maximum value = %d , index = (%d,%d).\', v1, ind(ind1), ind1 ));
[b]
F = [1 5 4 ;6 8 9 ;2 1 3];
[row , col] = size(F);
X = sprintf(\'The matrix F has %d rows and %d columns.\',row,col);
disp (X)
[v,ind]=max(F);
[v1,ind1]=max(max(F));
Y = sprintf(\'The maximum value of F is %d .\',v1);
disp (Y)
total = sum(diag(F));
Z = sprintf(\'The Sum of the diagonal Element is = %d .\',total);
disp (Z)

