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

1 view (last 30 days)
>> 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 Comments

Sign in to comment.

Accepted Answer

Cris LaPierre
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 Comment
Abdallah
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.

Sign in to comment.

More Answers (0)

Tags

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by