Error while Reading a image inside a user defined function

2 ビュー (過去 30 日間)
Prayag Bhatia
Prayag Bhatia 2019 年 2 月 13 日
コメント済み: Prayag Bhatia 2019 年 2 月 14 日
I am defining a function named corry and inside that function if I read a image using imread I get an error 'The expression to the left of the equals sign is not a valid target for an assignment'
function corry = gandhi_check(img)
{
IReal1 = imread('Real_4.jpg');
_real_check1 = imcrop(IReal1 , [754 123 120 129];
IReal = rgb2gray(IReal1) ;
real_check = rgb2gray(gandhi_real_check1) ;
p = corr2(real_check , img) ;
corry = p ;
}
I am getting error at the line of Imread. Can anyone help me with this error.

採用された回答

Cam Salzberger
Cam Salzberger 2019 年 2 月 13 日
Hello Prayag,
MATLAB does not use curly braces { } to demark functions, loops, conditionals, or other code blocks. Instead, MATLAB uses the keyword (like function, for, or if) to denote the beginning, and end statements to indicate the end of the block. I believe that MATLAB is interpreting the curly brace as belonging to the same code line as imread, and is erroring as a result.
-Cam
  1 件のコメント
Prayag Bhatia
Prayag Bhatia 2019 年 2 月 14 日
Thank you so much Cam !! Indeed was such a silly mistake.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by