Changing Variable from logical to double

조회 수: 17 (최근 30일)
Sivakumar Rajagopal
Sivakumar Rajagopal 2020년 4월 2일
편집: Adam Danz 2020년 4월 6일
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월 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일
"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개)

카테고리

Help CenterFile Exchange에서 Introduction 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