Why I get 1×0 empty double row vector?

Hi, I have problem with my code. I don't know why fidx1 is 1x0 empty double row vector?
min(oh1) and max(oh1) results are:
>>min(oh1)
ans = 102.8890
>> max(oh1)
ans = 106.2470
d1=[0 min(oh1) min(oh1)];
e1=[max(oh1) max(oh1) max([oh1 oh2 oh3 oh4 oh5 oh7 oh11 oh13 oh19 oh23 oh25 oh29 oh35 oh37])];
X1=[xq1];
Y1=[100*r1];
lidx1 = find(X1 == max(oh1));
Ylidx1 = Y1(lidx1);
fidx1 = find(X1 == min(oh1));
Yfidx1 = Y1(fidx1);

4 件のコメント

Walter Roberson
Walter Roberson 2020 年 12 月 27 日
Why do you assume that there is any relationship between xq1 and oh1? Why do you assume that there is bit-for-bit exact matches?
Aleksandra Pawlak
Aleksandra Pawlak 2020 年 12 月 27 日
Relationship between xq1 and oh1:
oh1L1=[104.154 103.962 104.171 104.119 104.093 104.006,......]
oh1L2=[103.735 103.517 103.727 103.718 103.753 103.674,......];
oh1L3=[103.666 103.491 103.674 103.657 103.666 103.596,......];
oh1=[oh1L1 oh1L2 oh1L3];
xq1 = (0:(max(oh1))/200:max(oh1));
Aleksandra Pawlak
Aleksandra Pawlak 2020 年 12 月 27 日
My code works only for max value.
There's something wrong with part:
fidx1 = find(X1 == min(oh1));
Yfidx1 = Y1(fidx1);
I can't understand this
Image Analyst
Image Analyst 2020 年 12 月 28 日

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

 採用された回答

Ive J
Ive J 2020 年 12 月 27 日
編集済み: Ive J 2020 年 12 月 27 日

0 投票

xq1 (and therefore X1) simply may don't contain min(oh1) since you are discretizing [0, max(oh1)]. What you can do is to find the idx corresponding to the closest value to min_oh1
max_oh1 = 104;
xq1 = 0:104/200:104;
[~, fidx1] = min(abs(xq1 - min(oh1)));

5 件のコメント

Aleksandra Pawlak
Aleksandra Pawlak 2020 年 12 月 27 日
104 result from rounding values in oh1 vector?
Ive J
Ive J 2020 年 12 月 27 日
no it's just a simple example.
oh1 = [104.154 103.962 104.171 104.119 104.093 104.006 103.666 ...
103.491 103.674 103.657 103.666 103.596];
xq1 = 0:max(oh1)/200:max(oh1);
find(xq1 == min(oh1)) % nothing's here
ans =
1×0 empty double row vector
[~, fidx1] = min(abs(xq1 - min(oh1)));
[xq1(fidx1), min(oh1)] % to compare
ans =
103.6501 103.4910
Aleksandra Pawlak
Aleksandra Pawlak 2020 年 12 月 27 日
It works, thank you!
But I have small question by the way: When I should use something like [~, fidx1]= instead of just fidx1= ?
Ive J
Ive J 2020 年 12 月 27 日
The first output argument is the minimum value itself, and the second one is it's index.
Aleksandra Pawlak
Aleksandra Pawlak 2020 年 12 月 27 日
Ok, get it, thanks!

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

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by