フィルターのクリア

How to write a pattern for any different values

4 ビュー (過去 30 日間)
Noah Kilps
Noah Kilps 2020 年 10 月 14 日
コメント済み: Steve Eddins 2020 年 10 月 14 日
Hello,
Sorry if my title does not make much sense. Basically, I want to use the strfind command on the variable X. I've attached it in an excel file. I want to simply find the places that the variables changes from one number to another, but I'm not exactly sure how to write this pattern. How should I do this?
  1 件のコメント
Noah Kilps
Noah Kilps 2020 年 10 月 14 日
I forgot to attach the file, here it is.

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

採用された回答

Steve Eddins
Steve Eddins 2020 年 10 月 14 日
T = readtable('matlab_question2.csv');
idx = find(diff(T.x))
idx =
119
314
351
381
...
The first line reads your CSV file into a table that contains the variable x.
The function diff computes the differences between adjacent elements of its input.
The function find then returns the indices where the adjacent element differences are nonzero. These are the locations where the values change. For example:
>> idx(1)
ans =
119
>> T.x(117:121)
ans =
56.3279
56.3279
56.3279
0
0
  4 件のコメント
Image Analyst
Image Analyst 2020 年 10 月 14 日
Can you please "Accept this answer"?
Steve Eddins
Steve Eddins 2020 年 10 月 14 日
Adam, I keep forgetting that readmatrix has already shipped, lol.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by