フィルターのクリア

How to plot data over a desired range in one matrix based on values from a different matrix?

2 ビュー (過去 30 日間)
Hello,
I have created two different matrices at this point. The first is a simple 2x1 matrix with the values of 548 and 5948. These values correspond to the beginning and end times of the data that I would like to plot in the second much larger matrix (166088x3). The data file is too large to attach but takes the form below:
0 0.0515833570000000 0.00455798800000000
2 0.0589201300000000 0.00452135800000000
4 0.0726283130000000 0.00436905700000000
6 0.0712768020000000 0.00442689300000000
8 0.0448258020000000 0.00440375800000000
10 0.0697322180000000 0.00448665700000000
12 0.0494595540000000 0.00448858500000000
14 0.0266769400000000 0.00443074900000000
16 0.0342067870000000 0.00447123400000000
18 0.0602716410000000 0.00441339800000000
Here, the first column is time, the second column is upstream pressure, and the third column is downstream pressure. I would like to plot time vs. downstream pressure (the first and third columns). I understand how one would manually plot the desired data but I wish to create a robust code that can plot data between any of the time points that I provide in the first matrix. My first intuition is that a loop is likely necessary, however I am unsure how to tackle this problem efficiently. Any help would be greatly appreciated.
Thank you so much for your help.

採用された回答

Voss
Voss 2022 年 1 月 6 日
time_limit = [548 5948];
idx = data(:,1) >= time_limit(1) & data(:,1) < time_limit(2);
plot(data(idx,1),data(idx,3));

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by