Finding x value for y values on a dataset.

4 ビュー (過去 30 日間)
Alexander Huang
Alexander Huang 2021 年 11 月 16 日
コメント済み: Alexander Huang 2021 年 11 月 16 日
Say I have this matrix:
y = [-5 -4 -3 -2 -1 0 1 2 3 4 5;
-6 -5 -4 -3 -2 -1 0 1 2 3 4;
0 1 2 3 4 5 6 7 8 9 10];
And this is my domain:
x = [0 1 2 3 4 5 6 7 8 9 10 ];
and I plot them like so
plot(x, y)
How can I find the x values when my y values cross a value like 3.5?
I would like my output to be
output = [9 10 5]
Thanks!

採用された回答

the cyclist
the cyclist 2021 年 11 月 16 日
The algorithm you want is not perfectly clear, and I can't see quite how you get the output from your input. But it seems that you want something like this?
y = [-5 -4 -3 -2 -1 0 1 2 3 4 5;
-6 -5 -4 -3 -2 -1 0 1 2 3 4;
0 1 2 3 4 5 6 7 8 9 10];
nyrows = size(y,1);
output = zeros(1,nyrows);
for ny = 1:nyrows
output(ny) = find(y(ny,:)>3.5,1) - 1; % Not sure exactly which element you want
end
disp(output)
9 10 4
  1 件のコメント
Alexander Huang
Alexander Huang 2021 年 11 月 16 日
Exactly what I needed, thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by