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 Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by