Changing Variable from logical to double

Fx=edge(I1,'Sobel','vertical',0.001);
While executing above line the follwoing error message is received
"Variable Fx must be of data type double. It is currently of type logical. Check where the variable is assigned a value."
How change Fx type feom logical to double

8 件のコメント

Adam Danz
Adam Danz 2020 年 4 月 2 日
編集済み: Adam Danz 2020 年 4 月 3 日
I don't think that line caused the error. That line just assigns the output to Fx. If the answer I provided doesn't solve the problem please provide the full copy-pasted error message.
Sivakumar Rajagopal
Sivakumar Rajagopal 2020 年 4 月 3 日
Variable img_heq must be of data type uint8. It is currently of type double. Check where the variable is assigned a value.
Adam Danz
Adam Danz 2020 年 4 月 3 日
This error message doesn't match the error message in your question. It references a different variable name and describes a different error.
It also doesn't appear to be a complete error message showing the line number and other impotant bits of information.
Sivakumar Rajagopal
Sivakumar Rajagopal 2020 年 4 月 3 日
I have modified it as
Gx=[-1,0,1;-2,0,2;-1,0,1];
Fx=conv2(I,Gx);
Now it is showing the following error
Variable Fx must be of size [500 500]. It is currently of size [502 502]. Check where the variable is assigned a value.
Adam Danz
Adam Danz 2020 年 4 月 3 日
編集済み: Adam Danz 2020 年 4 月 3 日
1) What is I?
2) Are you using Matlab's conv2() or are you using a different function with the same name? To verify, run,
which conv2
3) Again, I don't think you're sharing the full error message (all of it).
Sivakumar Rajagopal
Sivakumar Rajagopal 2020 年 4 月 3 日
1) A=img;T=rgb2gray(A); I = double(T);
2) Yes Matlab's conv2()
3) It is a error message generated under coursera Matlab valiation
Adam Danz
Adam Danz 2020 年 4 月 3 日
編集済み: Adam Danz 2020 年 4 月 3 日
Again, it makes no sense to me why this line
Fx=conv2(I,Gx);
would generate this specific error
Variable Fx must be of size [500 500]. It is currently of size [502 502] . . . . .
That line is merely assigning the output to variable Fx. I think the error is being generated somewhere else in a line where you're using the variable Fx. Could you provide a screenshot of the error and the code that causes the error? I'm unfamiliar with Coursera Matlab - does that mean you are running matlab online through a coursera portal or are you running Matlab on your computer using a license provided by Coursera?
If the output has an unexpected size, read about the conv2 output size here.
To show that the code should not cause an error (given a proper image file), this runs fine:
RGB = imread('peppers.png'); % Built-in matlab file
I = rgb2gray(RGB);
Gx=[-1,0,1;-2,0,2;-1,0,1];
Fx=conv2(double(I),Gx);
Sivakumar Rajagopal
Sivakumar Rajagopal 2020 年 4 月 3 日
Ok Let me try

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

 採用された回答

Adam Danz
Adam Danz 2020 年 4 月 2 日
編集済み: Adam Danz 2020 年 4 月 6 日

0 投票

"How change Fx type from logical to double"
FxDlb = double(Fx);
alternatively,
FxDlb = Fx * 1;
% or
FxDlb = Fx + 0;

2 件のコメント

Sivakumar Rajagopal
Sivakumar Rajagopal 2020 年 4 月 6 日
ok Thanks
Adam Danz
Adam Danz 2020 年 4 月 6 日
編集済み: Adam Danz 2020 年 4 月 6 日
Glad I could help.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeIntroduction to Installation and Licensing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by