フィルターのクリア

Extract upper triangle of matrix (using vector different from diagonal)

8 ビュー (過去 30 日間)
Philipp Brunnbauer
Philipp Brunnbauer 2023 年 3 月 13 日
コメント済み: Philipp Brunnbauer 2023 年 3 月 15 日
Hello, I am trying to extract some data from a matrixt, wherein the upper "triangle" contains the signal I am interested in. I can extract a big chunk of ut using triu(), the issue is the lower bound is not a diagonal, but steeper than the diagnonal (for every row there is about 1.5 columns if that makes sense), causing the upper section to be cut using triu(). Is there a way of doing it with a nested for loop or the like? I am banging my head against a wall here. See pictures for reference.

回答 (1 件)

Cameron
Cameron 2023 年 3 月 13 日
If you have the data in a form of X and Y data points, you can do something like this
x = randi([220,800],100,1); %100 random x data points between 220 and 800
y = randi([200,600],100,1); %100 random y data points betwen 200 and 600
myindx = y - 0.5*x >= 0; %index which is above a line from x1 = 400, y1 = 200,
%x2 = 800, y2 = 400. This gives a slope of 0.5 and y intercept of 0.
NewX = x(myindx); %x values only above your myindx line
NewY = y(myindx); %y values only above your myindx line
plot(x,y,'o',...
NewX,NewY,'o',...
[400,800],[200,400],'-k')
  2 件のコメント
Philipp Brunnbauer
Philipp Brunnbauer 2023 年 3 月 13 日
this is great, will try it! Thanks Cameron
Philipp Brunnbauer
Philipp Brunnbauer 2023 年 3 月 15 日
Hey Cameron, I had to modify the script a bit and now have a working version of it - thanks a lot!

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

カテゴリ

Help Center および File ExchangeOperating on Diagonal Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by