Question
In Matlab


A= 3 -5 6 ( 15 7 9 13 5 -4 12 10 2 8 11 4 1 For the matrix A in problem-2, use MATLAB to carry out the following instructions
0 0
Add a comment Improve this question Transcribed image text
Answer #1

All questions done using Matlab..

Code:

clc
clear all
close all
A=[ 3 7 -4 12 ; -5 9 10 2 ; 6 13 8 11 ; 15 5 4 1];
disp('A = ')
disp(A);
[r c]= size(A);
%% finding the max and min values in each column
disp('=====================');
fprintf('column \t min \t max \n');
for i=1:c
x = A(:,i);
x=x';
minimum =min(x);
maximum =max(x);
fprintf('%d \t \t %d \t \t %d \n',i,minimum,maximum);
end
disp('=====================');
%% finding the max and min values in each row
fprintf('row \t min \t max \n');
for i=1:r
x = A(i,:);
minimum =min(x);
maximum =max(x);
fprintf('%d \t \t %d \t \t %d \n',i,minimum,maximum);
end
%% sorting column in ascending order
%% sort function will sort in columns
P = sort(A);
disp('===========P===========');
disp(P);
%% to sort the matrix in row wise
% transpose matrix -> sort -> transpose
Q = (sort(A'))';
%Q = sort(A,2);
%% or you can use sort(A,Dim) = sort(A,2) to sort rowwise
disp('===========Q===========');
disp(Q);

Screen shots..

4 5 6 7 8 9 10 11 12 13 - - 14 - A=[ 37 -4 12 ; -5 9 10 2 ; 6 13 8 11 ; 15 5 4 1]; disp(A = ) disp (A); [r c] = size (A); %output :

A = 7 12 3 -5 -4 10 2 9 13 6 8 11 15 5 4 1 ===== ====== column min max 1 15 -5 5 2 13 3 10 -4 1 4 12 ======= min max LOW 1 2

Add a comment
Know the answer?
Add Answer to:
In Matlab A= 3 -5 6 ( 15 7 9 13 5 -4 12 10 2...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • cope the code please thanks Write a MATLAB code to obtain the following. Keep your code...

    cope the code please thanks Write a MATLAB code to obtain the following. Keep your code commented whenever required. Copy your source code and command widow outcomes and screen shots of any plots in your solution. Generate a matrix "A" as follow. A= 16 6 8 2 10 18 12 14 4 I. II. Divide the matrix A by 2 and store the result in a matrix B. Combine matrices A & B to obtain the following matrix C. Also...

  • matlab help Write a script to manipulate the array A = [2 1 4 3 6...

    matlab help Write a script to manipulate the array A = [2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19] to be in descending order without using the sort function. You must do everything using array manipulation in MATLAB (i.e. you cannot sort it by hand and then hardcode it, you cannot simply create the array 1:20, you cannot simply add .rej3mat(J-l 1],1,10) to A). Write a script that...

  • In Matlab Consider the array A. 10 3 5 -4 12 -5 9 2 A= 6...

    In Matlab Consider the array A. 10 3 5 -4 12 -5 9 2 A= 6 13 -8 11 115 -5 4 1 Write a program that computes the array B by computing the square of all the elements of A whose value is greater than 10 and multiplying 5 to each element that is less than or equal to 10. You need to use a logical array as a mask.

  • MATLAB QUESTION !!! PLEASE USE MATLAB FOR BOTH QUESTIONS!!! THANKS 3) Below is a matrix of...

    MATLAB QUESTION !!! PLEASE USE MATLAB FOR BOTH QUESTIONS!!! THANKS 3) Below is a matrix of random numbers. Find the mean, median, and mode of the matrix. B=[0 1 2 3 4 50689 23092 6 8 407] Sort Matrix Z so that the largest numbers of each row are in the first column and smallest numbers descend towards the last column. Must use sort function. 4) Create a matrix X so that the first row has values from 0 to...

  • Refer to the following array definition for questions 1 & 2 int numberArray[9)[11] 1. Write a...

    Refer to the following array definition for questions 1 & 2 int numberArray[9)[11] 1. Write a statement that assigns 145 to the first column of the first row of this array. 2. Write a statement that assigns 18 to the last column of the last row of this array. values is a two-dimensional array of floats, with 10 rows and 20 columns. Write code that sums all of the elements in the array and stores the sum in the variable...

  • 2. (10 pts. Please perform the following calculations via MATLAB a. Calculate e3!/pi and round the...

    2. (10 pts. Please perform the following calculations via MATLAB a. Calculate e3!/pi and round the answer to the nearest integer (all via MATLAB commands) b. Calculate cos(wt) for t (time) from 0 seconds to 10 seconds (with 1 second increments – created via colon operator) where w = 30°/seconds c. Please sort the values of the vector given below from smallest to largest and save it as another single column vector and G = [68, 83,61, 70, 75, 82,57,5,...

  • Using Matlab Write a program which will: a. Accept two numbers from the user m and...

    Using Matlab Write a program which will: a. Accept two numbers from the user m and n b. Define an array with the dimensions a(n,m) and fill it with random numbers in the range of -100 to 100 inclusive. c. Provide the user the following menu from which he can select: 1. Sum of all elements in the array. Print the result. 2. Sum of the element in a row that he’ll specify. Print the result. 3. Sum of the...

  • using matlab Create the following matrix B. [18 17 16 15 14 13] 12 11 10...

    using matlab Create the following matrix B. [18 17 16 15 14 13] 12 11 10 9 8 7 6 5 4 3 2 1 Use the matrix B to: (a) Create a six-element column vector named va that contains the elements of the second and fifth columns of B. (6) Create a seven-element column vector named vb that contains elements 3 through 6 of the third row of B and the elements of the second column of B. Create...

  • Use Matlab Given: x = [13, 5, 7, 9, 1, 4, 7, 10, 13] Use one...

    Use Matlab Given: x = [13, 5, 7, 9, 1, 4, 7, 10, 13] Use one 'for loop' to create the matrix y of dimension 5X2, using the index to program the address and the value of each element of y; and y = x' Given, x = [2, 3, 4, 5, 3, 4, 5, 6] Use two 'for loops' to create the matrix of dimension 4X2 Use a while statement to determine when the sum of the numbers in...

  • Programming Assignment 6 Write a Java program that will implement a simple appointment book. The ...

    Programming Assignment 6 Write a Java program that will implement a simple appointment book. The program should have three classes: a Date class, an AppointmentBook class, and a Driver class. • You will use the Date class that is provided on Blackboard (provided in New Date Class example). • The AppointmentBook class should have the following: o A field for descriptions for the appointments (i.e. Doctor, Hair, etc.). This field should be an array of String objects. o A field...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT