Why I get extra columns with irrelevant results?

7 ビュー (過去 30 日間)
Stelios Fanourakis
Stelios Fanourakis 2019 年 2 月 24 日
コメント済み: Stelios Fanourakis 2019 年 2 月 25 日
Hi
I use those lines to get the number of pixels among several rows and columns
for col = 390 : 466
h = imdistline(gca,[427 427],[215 370]);
dist(col) = getDistance(h)
end
Then I use this line to export them in excel
data = [dist(:)];
t = table(data);
writetable(t,'YourFile555.xls','Sheet',1,'Range','AD1:AD520')
Other times, when the Range exceeds the pixel values of the image I am supposed to get from dist, then the exceeding cells of the excel would get 0 value.
In my case, I get the correct values up until the 466 column as I have defined in the for loop and then it fills with irrelevant values, the rest of the columns until 520 as I have declared in the Range. Why is that?
155 is the correct value of the image I am using, the rest 83 that you see are values of a previous image. Not the one I am currently use. Why Matlab gets confused??
Columns 457 through 475
155 155 155 155 155 155 155 155 155 155 83 83 83 83 83 83 83 83 83
Columns 476 through 494
83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83
Columns 495 through 508
83 83 83 83 83 83 83 83 83 83 83 83 83 83
I don;t have any other line in the code that refers to the previous image. Just the ones I write here.
Any possible explanation please?

採用された回答

Matt J
Matt J 2019 年 2 月 24 日
My guess is that you are writing into the same file as the previous image, but with a shorter list of values. The preceding values are still there because you did not clear them and the list of new values is too short to overwrite them all.
  5 件のコメント
Stelios Fanourakis
Stelios Fanourakis 2019 年 2 月 25 日
Yeah, thanks. Most probably this was the case.

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by