# find(V,1) returns an index that doesn't match with the plot

1 view (last 30 days)
Abdallah on 5 Aug 2022
Commented: Abdallah on 5 Aug 2022
>> find(SL_B_Optml,1)
ans =
381
>> plot (linspace(1,1441-(T_B+1)+1,1441),SL_B_Optml);
>> hold on
>> plot([381 381],[0 1.4],'LineWidth',1)
First of all, the find funciton tells us that my SL_B_Optml array reaches a non-zero value for the first time at the x=381.
The plots written above give this: We can clearly see that SL_B_Optml array reaches the first non-zero value at x=358.3.
I don't understand what's happening here.
##### 2 CommentsShowHide 1 older comment
Abdallah on 5 Aug 2022
>> size(SL_B_Optml)
ans =
1 1441

Cris LaPierre on 5 Aug 2022
Find tells you the index value of the elements of SL_B_Optml that meet your criteria. It therefore will be an integer value. However, that is different than an x-value of 381. Here, your x values are linspace(1,1441-(T_B+1)+1,1441).
You should therefore highlight your point doing something like this:
x=linspace(1,1441-(T_B+1)+1,1441);
plot([x(381) x(381)],[0 1.4],'LineWidth',1)
We don't have your values, so I can't check if there is anything else wrong.
##### 1 CommentShowHide None
Abdallah on 5 Aug 2022 Find tells you the index value of the elements of SL_B_Optml that meet your criteria. It therefore will be an integer value. However, that is different than an x-value of 381.
This.You're right, sir, I get it now, thanks.

R2017b

### Community Treasure Hunt

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

Start Hunting!