필터 지우기
필터 지우기

need help with task 2, heres what i have so far

조회 수: 1 (최근 30일)
Alex Doan
Alex Doan 2020년 4월 1일
편집: Rik 2020년 4월 1일
clc, clear all, close all
%Task 1
square = input('Enter a proposed magic square: ');
[R,C]=size(square);
while R~=C
warning('User did not enter a square matrix, try agian');
square = input('Enter a proposed magic square: ');
[R,C]=size(square);
end
%Task 2
for i=1:R
for j=1:C
if mod(square(i,j),2)~=0
end
end
end
TASK 1: Matrix size (3 – 5 min) Prompt the user to enter their proposed magic square in a single input statement (e.g. [1 2 3; 4 5 6; 7 8 9] – note that this example is a square matrix but is not a magic square). Determine if the matrix entered is a square matrix. If it is not, inform the user of their mistake and prompt the user to re-enter another matrix. Repeat this check until the user successfully enters a square matrix.
TASK 2: Whole numbers (10 – 15 min) Check that each value in the matrix is a whole number. If it is not, prompt the user to round the number up or down (see example menu statements). Based on their choice, replace the decimal number with the rounded whole value.
  댓글 수: 1
Rik
Rik 2020년 4월 1일
편집: Rik 2020년 4월 1일
This isn't your first question. Please take the time to use the layout tools to make your question readable.
What have you tried so far? How would you determine if a value is a whole number? Have you read the documentation for the menu function? How would you round a number up or down?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by