I am new in matalb.

조회 수: 2 (최근 30일)
vibhuti mahant
vibhuti mahant 2021년 10월 11일
편집: Walter Roberson 2021년 10월 12일
  1. You have been asked to write a function that processes images. An image is represented by a matrix in Matlab. In order to do some processing corner values of the matrix are required. Write a function that returns four outputs for four corners. e.g
A = [1, 2, 3; 4, 5, 6; 7, 8, 9];
[TL, TR, BL, BR] = imageCorners(A)
TL = 1, TR = 3, BL = 7, BR = 9
  댓글 수: 3
Steven Lord
Steven Lord 2021년 10월 11일
This sounds like a homework assignment. If it is, show us the code you've written to try to solve the problem and ask a specific question about where you're having difficulty and we may be able to provide some guidance.
If you aren't sure where to start because you're not familiar with how to write MATLAB code, I suggest you start with the MATLAB Onramp tutorial (https://www.mathworks.com/support/learn-with-matlab-tutorials.html) to quickly learn the essentials of MATLAB.
If you aren't sure where to start because you're not familiar with the mathematics you'll need to solve the problem, I recommend asking your professor and/or teaching assistant for help.
vibhuti mahant
vibhuti mahant 2021년 10월 12일
sure i do that thank you so much for help.

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

채택된 답변

Image Analyst
Image Analyst 2021년 10월 11일
편집: Image Analyst 2021년 10월 11일
You can get a value from A by specifying the row and column, like A(row, column). Rows and columns start numbering at 1. The last one is referenced by the shortcut word "end", like A(1, end) or A(end, end), and so on. So use 1 and end in between the parentheses to get the corresponding corners. Of course you'll need all 4 combinations of 1 and end to get all 4 corners.
Use function to define the function
function [TL, TR, BL, BR] = imageCorners(A)
TL = ........
and then when you call it, define A and accept all 4 outputs. So your script would look like:
A = [1, 2, 3; 4, 5, 6; 7, 8, 9];
[TL, TR, BL, BR] = imageCorners(A) % Call the function in the main part of the script.
% Define the function below the main part, or in a separate m-file called
% imageCorners.m. If the function is in your test script file, then be
% sure to end your function with the "end" keyword.
function [TL, TR, BL, BR] = imageCorners(A)
TL = ........ You do this part yourself...
end
  댓글 수: 3
Image Analyst
Image Analyst 2021년 10월 12일
@vibhuti mahant, yes you do. The variables DO contain the proper values.
A = [1, 2, 3; 4, 5, 6; 7, 8, 9];
[TL, TR, BL, BR] = imageCorners(A)
function [TL, TR, BL, BR] = imageCorners(A)
TL= A(1,1);
TR=A(1,end);
BL=A(end,1);
BR=A(end,end);
end
Take the semicolon off the call if you want to see them printed to the command window:
TL =
1
TR =
3
BL =
7
BR =
9
vibhuti mahant
vibhuti mahant 2021년 10월 12일
ok i got it thank you so much its g8t help.
A =
1 2 3
4 5 6
7 8 9
TL =
1
TR =
3
BL =
7
BR =
9

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

추가 답변 (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