Question
MATLAB
Problem-4 A square matrix is a matrix that has the same number of rows and columns. Write a function issquare that will receive a matrix as input, and return logical 1 for true if it is a square matrix or logical 0 for false if it is not. The function should also display a sentence stating whether the inputted matrix is square or not.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

%%Save as issquare.m

function result=issquare(array)

%%get rows and columsn of array

[rows cols]=size(array)

if rows==cols

%%print message

fprintf('Matrix is square matri\nx')

%%set result=true

result= true;

else

fprintf('Matrix is not-square matrix\n')

result=false;

end

end

-----------------------------------------------------

A=[1 2 3 ;4 5 6; 1 2 3];

Call with the file name

issquare(A)

Add a comment
Know the answer?
Add Answer to:
MATLAB A square matrix is a matrix that has the same number of rows and columns....
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
  • 1. Write a MATLAB function that takes a matrix, a row number and a scalar as...

    1. Write a MATLAB function that takes a matrix, a row number and a scalar as arguments and multiplies each element of the row of the matrix by the scalar returning the updated matrix. 2. Write a MATLAB function that takes a matrix, two row numbers and a scalar as arguments and returns a matrix with a linear combination of the rows. For example, if the rows passed to the function were i and j and the scalar was m,...

  • how can i solve the system of these magic matrices using matlab software ? Exercice 3. A magic matrix is a square matrix with integer entries in which all the rows, columns and the two diagona...

    how can i solve the system of these magic matrices using matlab software ? Exercice 3. A magic matrix is a square matrix with integer entries in which all the rows, columns and the two diagonals have the same sum. For example, A- 3 5 7 4 9 2 Complete the following magic matrices 17? ?? 3 ? 2 ? 2? ? Do the following steps in each case: 1. Write the system of equations and put it under the...

  • Create a matrix with 3 rows and 4 columns. Every element in the first row should...

    Create a matrix with 3 rows and 4 columns. Every element in the first row should be 0, every element in the second row should be 1, and every element in the third row should be 2. But don’t just type out all the numbers. Use some ingenuity. Display the matrix using MATLAB.

  • Let U be a square matrix with orthonormal columns. Which of the following is true of...

    Let U be a square matrix with orthonormal columns. Which of the following is true of the columns of U? They are the same as the rows of U. The inner product of each pair of column vectors is 0. Each column vector has unit length. They are linearly independent B, C, D are correct. A, C, D are correct. All A, B, C, D are correct. Next Previous Let U be a square matrix with orthonormal columns. Which of...

  • 9. Lo Shu Magic Square The Lo Shu Magic Square is a grid with three rows and three columns that h...

    9. Lo Shu Magic Square The Lo Shu Magic Square is a grid with three rows and three columns that has the following properties: The grid contains the numbers 1 through 9 exactly. The sum of each row, each column, and each diagonal all add up to the same number. This is shown in the following figure · 15 4 9 2-15 3 5 7-15 81 615 15 15 15 15 Write a program that simulates a magic square using...

  • A matrix with dimensions m by n, where m > n, has fewer rows than columns.

    Enter T or F depending on whether the statement is true or false. (Only ONE attempt allowed.) (You must enter Tor F -- True and False will not work.)_______  1. A matrix with dimensions m by n, where m > n, has fewer rows than columns._______  2. The 3rd row, 4th column entry of a matrix is below and to the right of the 2nd row, 3rd column entry.

  • MATLAB: write a function that retuns logical true of vector or matrics or scaler is empty...

    MATLAB: write a function that retuns logical true of vector or matrics or scaler is empty Write a function that retuns logical true of vector or matrics or scaler is empty %% P2: Check for an empty matrix % Write a function myIsEmpty which takes one input (scalar, vector, matrix, ...) % and returns logical true if the input is empty and false otherwise. % DO NOT USE MATLAB's isempty FUNCTION! % % Example: An input of [] should result...

  • Theory: A vector with nonnegative entries is called a probability vector if the sum of its entries is 1. A square matrix...

    Theory: A vector with nonnegative entries is called a probability vector if the sum of its entries is 1. A square matrix is called right stochastic matrix if its rows are probability vectors; a square matrix is called a left stochastic matrix if its columns are probability vectors; and a square matrix is called a doubly stochastic matrix if both the rows and the columns are probability vectors. **Write a MATLAB function function [S1,S2,P]=stochastic(A) which accepts a square matrix A...

  • I'm having trouble sorting this square matrix (a 2d array that has number of rows and...

    I'm having trouble sorting this square matrix (a 2d array that has number of rows and same number of column n x n) using row-wise approach in C programming. Please help me program this in C to sort it using row-wise approach, here is the code: #include <stdio.h> #define MAX 100 int main() { int mat[MAX][MAX]; int i, j, m, n; int rowsum, columnsum, diagonalsum; int k; int magic = 0; int transpose[MAX][MAX]; printf("Enter the # of rows and columns...

  • Define a two-dimensional int array which has 5 rows and 3 columns. The elements in array...

    Define a two-dimensional int array which has 5 rows and 3 columns. The elements in array is randomly initialized (using Math.random()). Write a method to find the maximum value in this two dimensional array; Write a method to find the average value in the array; Write a method to count how many elements are smaller than average; Write a method to copy contents in a two-dimensional array to a one-dimensional array. The method will return this one-dimensional array. Method is...

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